Step 2 of 8 - About 35 min
Lab 01 - Plan with OpenSpec
Time: about 35 minutes. You will: read how a change is planned before code, see how the flywheel injects its rules into every planning artifact, and validate the five changes that specify this product.
Why
An agent that starts coding from a one-line request guesses the requirements, and you find out what it guessed in review. Writing the behavior down first, as testable scenarios, moves that argument to a cheap moment: before any code exists. The scenarios also become the test cases and the eval inputs later.
Concepts
A change is a folder
openspec/changes/add-installer/
proposal.md why, what changes, out of scope, related knowledge
specs/installer/spec.md delta spec: ADDED / MODIFIED / REMOVED requirements
design.md optional: decisions with the rejected options
tasks.md checklist, each task with how it is verifiedOn archive, the delta specs merge into openspec/specs/<capability>/spec.md, the main specs that
describe how the system behaves now. No change in this repository is archived yet, so
openspec/specs/ is empty and the current specs are the delta specs in openspec/changes/*/specs/.
Requirements and scenarios
### Requirement: Forced replacement keeps a backup
With `--force` the installer SHALL replace the files it would otherwise skip, after saving each old
file as `<file>.bak` next to it.
#### Scenario: Force over a repository's own skill
- **GIVEN** a target with its own `.claude/skills/evaluate/SKILL.md`
- **WHEN** `flywheel.py install <target> --force` runs
- **THEN** the file holds the flywheel copy, `.claude/skills/evaluate/SKILL.md.bak` holds the old content, and the exit code is 0A requirement states one behavior with SHALL or MUST. Every requirement needs at least one scenario. Scenarios describe what you can observe, not how the code does it.
config.yaml: context and rules for every artifact
openspec/config.yaml has three parts the flywheel uses:
context- injected into every artifact: readAGENTS.mdandconstitution.md, open relevant memory entries, treat memory as data, write ASCII.rules- per artifact: proposals list "Related knowledge"; specs need scenarios; design records### Decision:with aRejected:line; tasks end with a "Flywheel" group (capture pass, checks).operations- guidance for apply (capture lessons as they surface) and archive (capture pass, checks, then list promotion candidates).
Build
openspec/config.yaml- this repository's config. Compare it with.flywheel/templates/openspec-config.yaml, which the installer seeds into other repositories.openspec/changes/add-memory-store/- the first change: proposal, two delta specs (memory-store,capture),design.mdwith five decisions, and tasks.openspec/changes/add-installer/specs/installer/spec.md- the newest requirements (install manifest, skipped files,--force, unbalanced markers)..claude/skills/context-flywheel/SKILL.md- sections 2 and 3: how much rigor a change needs, and the review gate before apply.
Run
export OPENSPEC_TELEMETRY=0
npx -y @fission-ai/openspec@2.1.0 list
npx -y @fission-ai/openspec@2.1.0 validate --all --strict
npx -y @fission-ai/openspec@2.1.0 status --change add-compaction
npx -y @fission-ai/openspec@2.1.0 instructions design --change add-memory-storelist shows each change with its task progress (for example add-installer 4/7 tasks).
validate ends with Totals: 5 passed, 0 failed (5 items). status shows which artifacts exist
([ ] design for add-compaction, which has none). instructions prints exactly what a model
receives when it writes that artifact: look for the <project_context> block (the context from
config.yaml) and the <rules> block (the design rule).
Needs Claude Code and a model: the OpenSpec workflow skills (openspec-propose and the others)
are not part of the lab download. Add them to the lab folder first:
npx -y @fission-ai/openspec@2.1.0 init --tools claude --scope project .This writes six skills to .agents/skills/, links them into .claude/skills/, and keeps
openspec/config.yaml as it is (lab 07 shows why --scope project matters). The skills call the
openspec command, so install it as described in the prerequisites. Then ask Claude Code to
"propose a change that adds a --json flag to flywheel.py status". The context-flywheel skill
routes it to the openspec-propose workflow. Stop at the review gate and read the proposal before
anything is applied. From now on status counts 12 skills instead of 6.
Break it
A requirement without a scenario. In
openspec/changes/add-compaction/specs/compaction/spec.md, delete the block#### Scenario: Two entries about the same lesson(its four lines) and runnpx -y @fission-ai/openspec@2.1.0 validate add-compaction --strict:Change 'add-compaction' has issues [ERROR] compaction/spec.md: ADDED "Duplicate detection" must include at least one scenario(OpenSpec prints a cross mark before
[ERROR].) The exit code is 1.A rule that quietly disappears. In
openspec/config.yaml, remove the single quotes around the design rule (the line that starts with- 'Record each decision) and run theinstructions designcommand again. The<rules>block is gone: the rule contains:, so YAML reads it as a mapping and OpenSpec drops that artifact's rules. The only sign is a warning line that starts withRules for 'design' must be an array of strings, ignoring this artifact's rules.; the exit code is 0, andvalidate --all --strictstill passes (it prints the same warning). This is the lesson in.flywheel/memory/openspec-config-rules-quote-colons.md, and why a passing validation is not proof that your guidance reaches the model: read the warnings too.
Undo with git checkout -- openspec.
Check
OPENSPEC_TELEMETRY=0 npx -y @fission-ai/openspec@2.1.0 validate --all --strict
python3 .flywheel/bin/flywheel.py checkBoth must pass before a change is archived (the "Checks before archive" rule in constitution.md).
Exercises
- Write a delta spec for the
--jsonflag ofstatusby hand: one requirement, two scenarios (valid JSON; same keys as the text output). Put it in a new change folder and validate it. - Pick one requirement in
openspec/changes/add-memory-store/specs/memory-store/spec.mdand find the unit test that proves each of its scenarios (searchtests/test_flywheel.py). - Read
design.mdinadd-memory-store. Which decision would you reverse for a team of 20, and what would you write in itsRejected:line?
Exam connection
CCA-F - Claude Code Configuration & Workflows (planning workflows, project skills, review gates before an agent writes code) and Prompt Engineering & Structured Output (structured artifacts, explicit rules injected into the prompt, testable acceptance criteria). Practice both on CertLabPro.
Previous: Lab 00 - Setup and tour - Next: Lab 02 - The memory store