WikiFrom Markdown spec to reviewed change

From Markdown spec to reviewed change: an AI pipeline for enhancement and large projects

Section 08 of 08Last reviewed 25 November 2026Applies to Any AI coding assistant · any CI system

When every engineer uses an AI assistant in their own way, nobody can say which project rules were followed or how a result was produced. This page describes the alternative: one approved Markdown spec per change, one pipeline that turns it into unit tests and code, and people deciding at three fixed gates. It is written for SIers and in-house development organisations that run maintenance and enhancement work at scale.

At a glance

  • Input: a Markdown spec for one change, reviewed and approved, stored in the repository next to the code. For that change it takes the place of the external design (外部設計 / 基本設計) and the detailed design (詳細設計).
  • Process: a job on the CI pipeline. It first generates unit tests from the spec, which people review and freeze. It then implements the change, builds and runs the tests, and repeats until they pass or a round limit is reached.
  • Output: a merge request containing the code, the test results, a requirement-to-test traceability matrix, and a record of how the result was produced. The pipeline never merges anything itself.
  • Control: project rules and frameworks are enforced by checks that fail the job, not by instructions in a prompt. These are lint, static analysis, architecture rules, scope limits, frozen tests and a full regression run.
  • Effect: the coding (製造) and unit-test (単体テスト) phases of each change largely move from people to the pipeline. Spec writing and review become the main human work. How much total effort this saves depends on the codebase and has to be measured; see the pilot.

Why free use of AI does not scale to enhancement work

An individual engineer with an AI assistant can be very productive. On a large system maintained by many people, often from several companies, the same freedom causes problems that project management cannot see until late:

  • Rules are applied unevenly. Coding conventions, framework usage and architecture rules live in documents. Whether the assistant was told about them depends on each person and each session.
  • Changes spread beyond their scope. An assistant asked to fix one thing may refactor three others. In enhancement work, each extra changed file is a regression risk and more to review.
  • Tests agree with the code by construction. When the same session writes the code and the tests, "all tests pass" only shows that the assistant agrees with itself. A shared misunderstanding passes silently. See independent oracle.
  • Nothing can be reproduced or audited. Prompts, context and model versions are not recorded. Nobody can show afterwards how a piece of code was produced.
  • Quality depends on who used the tool. Two teams using the same assistant produce different quality. For a prime contractor coordinating several subcontractors, that makes quality hard to manage.

The pipeline answers each of these the same way: it fixes the input, fixes the procedure, checks the output by machine, and puts people at the points where judgement is needed.

The pipeline, stage by stage

Two runs per change. The first produces tests and stops for review. The second starts only after those tests are approved and frozen.

One change request, from spec to merge request
StageDone byInputOutput
1. Write the specSE (person)Change request, existing codeMarkdown spec with numbered requirements and allowed paths
Gate 1Approver (person)SpecSpec merged with status: approved
2. Spec checkPipelineSpecFails if sections are missing, IDs are malformed or open questions remain
3. Generate testsPipeline (AI)Spec, public interfaces, existing tests, project rulesUnit tests tagged with requirement IDs, and a run showing that they fail before the change
Gate 2Reviewer (person)Generated tests against the specTests merged and frozen for this change
4. ImplementPipeline (AI)Spec, files under allowed paths, project rules, build and test outputCode change; capped loop of edit, build and test
5. Gates by machinePipelineThe changePass or fail on scope, frozen tests, skips, lint, static analysis, architecture rules, full regression and traceability
6. ReportPipelineEverything aboveMerge request with report, metadata and transcript
Gate 3Reviewer (person)Diff, spec, reportMerge, or return to the spec

If the loop reaches its round limit, or a machine gate keeps failing, the job stops. It leaves the branch, the logs and the transcript for an engineer. A stop is a result, not an error to hide. It usually points to a spec that is ambiguous or a change that is too large.

The shape of the two runs, written as GitLab CI. The same stages map directly to GitHub Actions, Jenkins or Azure Pipelines. The script names are placeholders for your own entry points; the checks inside them are shown further down this page and in the CI checklist.

YAML: shape of the pipeline, to adapt
# Run 1: triggered when a spec under specs/ is merged with status: approved
spec-check:
  script:
    - ./ci/spec_lint.sh "$SPEC"            # required sections, IDs, no open questions
generate-tests:
  needs: [spec-check]
  script:
    - ./ci/ai_generate_tests.sh "$SPEC"    # sees the spec, interfaces and existing tests only
    - ./ci/run_tests.sh --expect-fail      # new tests must fail before the change
    - ./ci/open_merge_request.sh tests "$SPEC"   # goes to Gate 2

# Run 2: triggered when the test merge request is approved and merged
implement:
  script:
    - ./ci/ai_implement_loop.sh "$SPEC"    # capped edit-build-test loop
machine-gates:
  needs: [implement]
  script:
    - ./ci/check_frozen_tests.sh           # tests unchanged since Gate 2
    - python3 ci/check_scope.py "$SPEC" "$BASE_SHA"
    - ./ci/check_no_skips.sh
    - ./ci/check_trace.sh "$SPEC"
    - ./ci/lint_and_static_analysis.sh     # your existing tools, project rules as errors
    - ./ci/run_tests.sh --all              # full regression, not only the new tests
report:
  needs: [machine-gates]
  script:
    - ./ci/build_report.sh "$SPEC"         # traceability, results, coverage, rounds, model, cost
    - ./ci/open_merge_request.sh code "$SPEC"    # goes to Gate 3; never merges

Where a test cannot even compile before the change, because the interface it calls does not exist yet, "fails before the change" means a compile failure in the new tests only. The reviewer at Gate 2 should see that failure.

The Markdown spec

The spec says what the change must do, not how the code should do it. Every requirement has an ID and acceptance criteria that a test can check. The front matter is read by the pipeline. The body is read by people and by the AI.

Markdown: specs/CR0142.md (example)
---
id: CR0142
title: Charge a fee when a reservation is changed late
status: approved            # draft | in-review | approved; the pipeline runs only on approved
author: <name>
approver: <name>
base_branch: main
allowed_paths:              # the only paths the implementation may change
  - src/reservation/**
  - src/billing/fee/**
must_not_change:            # stated explicitly so the reviewer and the check agree
  - src/billing/tax/**
  - db/migrations/**
---

## 1. Purpose
Why the change is needed, in two or three sentences.

## 2. Current behaviour (as-is)
What the system does today, naming the files and functions involved.
Written after reading the code, not from memory.

## 3. Requirements (to-be)
### CR0142-R01 A late change incurs a fee
- Given a reservation that starts less than 48 hours from now
- When the customer changes its date
- Then a fee of 20% of the original price is added, rounded down to the yen

### CR0142-R02 An early change is free
- Given a reservation that starts more than 48 hours from now
- When the customer changes its date
- Then no fee is added

### CR0142-R03 Exactly 48 hours counts as early
- ...

## 4. Interfaces
Signatures, request and response fields, error codes and messages added or changed.

## 5. Data
Tables and columns read or written. "None" is a valid answer.

## 6. Must not change
Behaviour that must stay as it is, in plain words. This is the regression scope.

## 7. Non-functional
Logging, performance limits and security rules that apply to this change.

## 8. Test notes
Boundary values, test data, external systems to stub.

## 9. Open questions
Must be empty before the status can be set to approved.

Rules that apply to every change do not go into each spec. Coding conventions, framework usage, forbidden patterns and naming are written once, in a project rules file that every job loads. That file is versioned and reviewed like code, because a change to it affects every later run. See configuration worth having for what such a file should contain. Wherever a rule can be checked by a tool, it is also added to lint, static analysis or an architecture test, so that breaking it fails the job.

The spec is where the effort moves

The pipeline is only as good as the acceptance criteria it is given. A vague requirement produces tests that check the wrong thing, and code that passes them. Writing testable requirements is a skill, and teams new to it need practice. Most of the training in a rollout goes into this, not into the AI tooling.

Mapping to the usual design documents

In a project that delivers design documents and test evidence as formal deliverables (成果物), each one still has a source. Most are produced from the pipeline's records instead of by hand.

Documents per change, before and after
DocumentWhere it comes from in the pipeline
External / basic design
(外部設計書・基本設計書)
The spec: purpose, requirements with acceptance criteria, interfaces. It covers the change only; system-level design documents stay as they are and are updated where the change affects them.
Detailed design
(詳細設計書)
Interfaces, data and constraints are in the spec. Internal logic is decided in the implementation and reviewed in the diff at Gate 3. If a detailed-design document is a contractual deliverable, it can be generated from the approved change. It must then be labelled as a description of what was built, not as a design written beforehand.
Unit test specification
(単体テスト仕様書)
Generated from the frozen test code, grouped by requirement ID.
Unit test results and evidence
(単体テスト結果・エビデンス)
The pipeline's test report, coverage and logs, stored as build artifacts with the commit they belong to.
Traceability matrixBuilt automatically: each requirement ID, the tests tagged with it, and their results.
Review recordThe approvals and comments on the merge requests at Gates 1, 2 and 3.

Three human gates

People decide at three fixed points. Between them, the pipeline runs without asking anyone.

  1. Gate 1: spec approval.The person who owns the requirement approves the spec. They check that every requirement is unambiguous, that the acceptance criteria can be tested, and that the allowed and must-not-change paths match the intended scope. Most later problems can be traced back to this gate.
  2. Gate 2: test approval.A reviewer reads the generated tests against the spec. Is every requirement covered? Would each test fail if its requirement were not met? Are the boundaries and error cases there? Did the tests fail before the change? Once merged, the tests are frozen for this change. Ideally the reviewer is not the author of the spec.
  3. Gate 3: change review.A reviewer reads the diff against the spec, using the report: traceability, test results, which files changed, how many rounds were needed. Passing tests are necessary but not enough. The reviewer also checks that the code does what the spec means and nothing more.

Automated controls in the pipeline

Each control fails the job. An instruction in a prompt is a request; a failing check is a control.

Checks that run on every change
ControlWhat it prevents
Spec lintRunning on a draft, or on a spec with open questions or requirements without IDs.
Scope checkChanges outside allowed_paths, the unrequested refactoring that makes enhancement work risky.
Frozen testsEditing the approved tests to make them pass. See the CI checklist.
No skip annotationsDisabling a failing test instead of fixing the code. See the CI checklist.
TraceabilityA requirement with no test.
Lint and static analysisBreaking coding conventions. Your existing tools and rule sets, with project rules set to error rather than warning.
Architecture testsForbidden dependencies, such as a presentation layer calling the database directly.
Full regression runBreaking behaviour outside the change. All existing tests run, not only the new ones.
Round limitAn endless loop and unbounded cost. See the CI checklist.
Pinned model and metadataResults that change silently when the model behind a name changes. See the CI checklist.
Locked-down permissionsThe job pushing to protected branches or widening its own access. See the CI checklist.

Two of these checks are specific to this pipeline. The scope check reads allowed_paths from the spec and fails if the change touches anything else. It needs Python 3 with PyYAML.

Python: ci/check_scope.py
import fnmatch, subprocess, sys
import yaml

spec_path, base = sys.argv[1], sys.argv[2]
with open(spec_path, encoding="utf-8") as f:
    front_matter = f.read().split("---")[1]
allowed = yaml.safe_load(front_matter)["allowed_paths"]

changed = subprocess.run(
    ["git", "diff", "--name-only", f"{base}...HEAD"],
    capture_output=True, text=True, check=True,
).stdout.split()

outside = [p for p in changed if not any(fnmatch.fnmatch(p, g) for g in allowed)]
if outside:
    print("changed outside allowed_paths:", *outside, sep="\n  ", file=sys.stderr)
    sys.exit(1)

The traceability check fails if a requirement ID in the spec appears in no test. Tests carry the ID in their name or in a comment. Replace tests/ with your test directories.

Shell: ci/check_trace.sh
spec="$1"
missing=0
for id in $(grep -oE '\bCR[0-9]+-R[0-9]+\b' "$spec" | sort -u); do
  if ! grep -rqw -- "$id" tests/; then
    echo "no test for $id" >&2
    missing=1
  fi
done
exit "$missing"

Controls specific to enhancement work

In new development the main risk is building the wrong thing. In enhancement work it is breaking something that already worked. Four additions address that:

  • Characterisation tests where coverage is thin. Many long-lived systems have few automated tests. Before the first change in such an area, add tests that record what the code does today, and review and freeze them. AI can draft these; a person confirms that the recorded behaviour is the intended one. Without them, "all tests pass" says little about regression.
  • An as-is section written from the code. The spec describes current behaviour with file and function names. This is the impact analysis. It is often the slowest part of an enhancement, and AI can help with it before the spec is written.
  • Explicit must-not-change paths and behaviour. Database migrations, shared libraries and interfaces used by other systems are excluded unless the spec names them. Where they are named, a specialist reviews them as well.
  • Full regression on every run. The complete existing suite runs before the merge request is opened, not only the tests for this change.

Running it on a large project

  • One spec, one change, one merge request. Large specs fit badly in the model's context and produce diffs too large to review. As a rule of thumb, split a spec that spans several modules or has more than about ten requirements. Treat this as a starting point to tune, not a measured limit.
  • Bounded context. Each job sees the spec, the files under its allowed paths, the interfaces they use and the project rules, not the whole repository. This keeps output focused and limits what leaves the network. See what is actually sent.
  • Parallel changes. Independent specs run as separate jobs on separate branches. Conflicts between them are resolved by people, or by rerunning a job on the new base.
  • One quality bar across teams and vendors. When every team and every subcontractor goes through the same pipeline and gates, quality no longer depends on who did the work. Evidence comes in the same format from everyone. For a prime contractor this is often the main benefit.
  • Approved model access and cost tracking. Jobs reach the model through the organisation's approved path, often a gateway. Each run records its token use or cost, so cost per change becomes visible. See the gateway model and the enterprise questions.

What changes for each role

Phases of one change, typical today and with the pipeline
PhaseTypical todayWith the pipeline
Requirements and external designSE writes a design documentSE writes the Markdown spec. Acceptance criteria must be testable, so this can take longer than before.
Detailed designSE or PG writes a detailed designInterfaces and data in the spec; internals reviewed in the diff
Coding (製造)PGPipeline; people review instead of write
Unit test design, run and evidencePG writes the test spec, runs tests, collects evidencePipeline generates tests (reviewed at Gate 2), runs them and produces the report
Code reviewReviewerReviewer, with the report and traceability
Integration and system test
(結合・総合テスト)
QA or SEUnchanged

The work that disappears is the mechanical part: typing the code, writing routine test cases, running them and collecting evidence. The work that remains needs more judgement: writing testable requirements, reviewing tests and reviewing diffs. Plan staffing and training around that shift.

Where it fits and where it does not

Use it first where the left column applies
Fits wellFits poorly, or needs preparation first
Bounded changes to an existing system: maintenance and enhancement (保守・改修)Changes whose requirements are still being discovered
Many similar change requests over timeOne-off changes to architecture that cut across the whole system
A build and tests that already run in CI without a personNo automated build or tests. Build those first; the pipeline cannot check what cannot run.
Written coding conventions and an established frameworkWork judged mainly by eye, such as visual design, or by measurement, such as performance tuning
An approved route to a model for this codeCode that may not be sent to any model. Here the method can still be used without AI generation, or with a model hosted inside the boundary.

Readiness checklist

  • Headless build and test. One command builds the system and runs its tests on a CI runner, with no manual step.
  • Reproducible test environment. Databases, external systems and test data can be started or stubbed in CI.
  • Lint and static analysis configured. The project's rules are expressed in tools where possible, and violations can fail a build.
  • Rules written down. Conventions, framework usage and forbidden patterns exist as a document that can become the project rules file.
  • Approved model access. The organisation has decided which route to a model this code may use, and on what terms. See the enterprise questions.
  • Branch protection. The pipeline's credentials cannot push to protected branches or approve merge requests.
  • Coverage known. You know where existing tests are thin, so characterisation tests can be planned there.
  • A baseline. Effort and defect figures for comparable past changes exist, or will be recorded, so the effect can be measured.

Measuring the effect in a pilot

This page gives no percentage for effort saved. The figure depends on how good the specs are, how much test coverage exists and how large the changes are. A number from another organisation does not tell you much about yours. Measure it instead:

  1. Choose one system and a set of comparable change requests. The sample should be large enough to compare; state its size when reporting.
  2. Take a baseline from similar past changes in the same system: effort per change by phase, and defects found in integration testing, system testing and after release.
  3. Run the pilot changes through the pipeline. Record effort per change for spec writing, Gate 2 review, Gate 3 review, rework and handling of stopped jobs.
  4. Compare total effort, not coding effort alone. Effort that moves from coding to spec and review is not a saving.
Metrics for the pilot report
MetricWhy it matters
Total effort per changeThe figure the business case depends on, compared with the baseline
First-pass rate at Gates 2 and 3Shows the quality of the specs and of the generated output
Stopped-job rate and reasonsPoints to specs that need work or changes that are too large
Rounds to greenShows how hard the changes are and drives run cost
Defects found laterIn integration testing, system testing and after release, compared with the baseline. Speed without this is not a result.
Run cost per changeModel usage and CI time, as recorded by the pipeline

Leave out lines of code and the number of tests generated. Both rise whether or not anything improved. The AI in development page explains why.

Working with GZLighTek

GZLighTek designs, builds and runs pipelines of this kind with SIers and in-house development teams, including in closed or audited environments. We can start at any of these points:

  • Readiness assessment. We review one system: its build, tests, CI, rules and model access. You receive a written list of gaps and a pilot plan.
  • Spec template and project rules. We adapt the spec template to your existing design-document standards and turn your conventions into a rules file and automated checks.
  • Pipeline build. We build the pipeline on the CI system you already use, behind your gateway or inside a closed network.
  • Pilot with measurement. We run real change requests through the pipeline and report against your own baseline.
  • Training. For SEs who write specs and for reviewers at Gates 2 and 3.
  • Delivery partner. We can also take on change requests through the pipeline as a development team, with your people approving at the gates.

Start a conversation

Tell us about the system: its size, languages and frameworks, the CI you use, how changes are approved today, and any constraints on where code may be processed. We will reply with how a pilot could look for that system.

Contact form · contact@gzlightek.com

Unofficial notes, not affiliated with or endorsed by Anthropic. Command names, flags and behaviour change between versions; the official documentation and the tool's own help output are authoritative. The snippets on this page are starting points to adapt and test in your own pipeline.