Kosten: The unit tests, flywheel.py, and openspec validate run offline at no cost. The model-based evals, the capture pass, promotion, and the compact-memory skill run in Claude Code and are billed to your Claude plan or API account.
Give a coding agent memory, skills, and rules that improve.
A coding agent starts every session with no memory of the last one. It repeats the mistake you corrected yesterday, and the notes you leave it grow until nobody reads them. The Context Flywheel fixes that with plain files and a small command-line tool: every change is planned as a spec first, what the agent learns is written down as short curated entries, lessons that keep coming back become skills or constitution rules through an evaluation gate and your approval, and a cleanup pass keeps the always-loaded context small.
In this lab you take the Context Flywheel apart one piece at a time, run every piece, break it on purpose, and finally install it into another repository. It runs inside Claude Code and uses OpenSpec for specs.
Related certifications
The lab follows the domains of these exams, so working through it is also exam preparation:
- Claude Certified Architect - Foundations (CCA-F) - the main one. The lab covers Claude Code Configuration & Workflows (CLAUDE.md imports, skills, subagents), Context Management & Reliability (a small always-loaded index, curated memory, stale detection), Prompt Engineering & Structured Output (specs with scenarios, eval files, a judge that returns strict JSON), Agentic Architecture & Orchestration (an orchestration skill, isolated generator and judge subagents, human approval gates), and Tool Design & MCP Integration (a deterministic CLI the agent calls, with clear errors and exit codes).
- NVIDIA-Certified Professional: Agentic AI (NCP-AAI) - Cognition, Planning, and Memory (what an agent should store, and how to deduplicate and retire it), Knowledge Integration and Data Handling (keeping stored knowledge fresh), and Safety, Ethics, and Compliance (keeping retrieved content from turning into instructions).
What you build
Quelltext des Diagramms
flowchart LR
P[Plan: OpenSpec change] --> A[Apply: agent writes code]
A --> C[Capture: memory entry]
C --> D{Seen in 2+ changes?}
D -->|no| M[(Memory store + index)]
D -->|yes| E[Evaluation gate]
E --> H{Human approves?}
H -->|yes| S[Skill or constitution rule]
M --> P
S --> P
M --> K[Compaction: verify, dedupe, retire]
K --> M- A spec-first workflow with OpenSpec: proposal, delta specs with GIVEN/WHEN/THEN scenarios, tasks, and a review before code.
- A memory store: one Markdown file per lesson, lifecycle in frontmatter fields, and a generated index that Claude Code loads on every request.
- Capture with a poisoning guard: lessons are written in the agent's own words, never copied from tool output.
- An evaluation gate: a fresh generator subagent per eval and a separate read-only judge.
- Promotion: a lesson that recurs across distinct changes becomes a skill or a rule, only after the gate passes and a human says yes.
- Compaction: stale detection, near-duplicate detection, and retirement, with no model rewriting entries.
- An installer that adds all of this to another repository without overwriting its own files.
Lab path
| # | Step | Time | CCA-F domain |
|---|---|---|---|
| 00 | Setup and tour | 20 min | Claude Code Configuration & Workflows |
| 01 | Plan with OpenSpec | 35 min | Claude Code Configuration & Workflows; Prompt Engineering & Structured Output |
| 02 | The memory store | 35 min | Context Management & Reliability; Tool Design & MCP Integration |
| 03 | Capture | 35 min | Context Management & Reliability |
| 04 | The evaluation gate | 35 min | Prompt Engineering & Structured Output; Agentic Architecture & Orchestration |
| 05 | Promotion | 40 min | Agentic Architecture & Orchestration; Claude Code Configuration & Workflows |
| 06 | Compaction | 30 min | Context Management & Reliability |
| 07 | Install into another repository | 35 min | Claude Code Configuration & Workflows; Tool Design & MCP Integration |
The steps follow the build order of the OpenSpec changes in openspec/changes/ (memory store and
capture, evaluation, promotion, compaction, installer). Each step takes 20-40 minutes (about 4.5
hours in all) and ends with a check you can run offline.
Prerequisites
- Python 3.10 or later. The CLI uses the standard library only; nothing to install.
- Claude Code, for the steps that run skills and subagents.
- Node.js 22.20 or later, for the OpenSpec CLI:
npx -y @fission-ai/openspec@2.1.0(ornpm i -g @fission-ai/openspec@2.1.0to get anopenspeccommand; the OpenSpec workflow skills you try with Claude Code in labs 01 and 07 call that command). SetOPENSPEC_TELEMETRY=0to turn off OpenSpec telemetry. - git, to undo your experiments and to review diffs.
Get the lab
- Download the lab from its page on CertLabPro: certlabpro.com/labs/ai-context-flywheel (Download the lab; the download includes the unit tests).
- Unzip it and open a terminal in the folder:
cd ai-context-flywheel
git init -q && git add -A && git commit -qm "lab baseline" # so you can undo experimentsQuick commands
python3 -m unittest discover -s tests # 55 unit tests, offline
python3 .flywheel/bin/flywheel.py check # memory, index, skills, agents, evals, ASCII
python3 .flywheel/bin/flywheel.py status # store summary
OPENSPEC_TELEMETRY=0 npx -y @fission-ai/openspec@2.1.0 validate --all --strict
python3 .flywheel/bin/flywheel.py install /path/to/repo --dry-run # preview an installWhat runs offline and what needs a model
| Runs offline, no model, no cost | Needs Claude Code and a model |
|---|---|
The unit tests in tests/ |
The golden-set evals (evaluate skill) |
Every flywheel.py command (check, new, verify, install) |
The capture pass and the capture-observation skill |
openspec validate, show, status, instructions |
Promotion (promote-skill, promote-constitution-rule) |
The compact-memory skill and its curator agent |
Honest status: the offline column is tested. The model column is written and reviewed, but the golden-set evals have not been run yet, so there are no recorded scores. Running them is part of step 04, and the cost goes to your Claude plan or API account.
Project layout
ai-context-flywheel/
README.md this overview
lab.json lab metadata (steps, related certifications)
labs/NN-name/README.md one guide per step
AGENTS.md grounding for agents working in this repository
CLAUDE.md imports AGENTS.md, constitution.md, and the memory index
constitution.md rules that must hold for every change
.claude/skills/ the six flywheel skills
.claude/agents/ flywheel-judge, flywheel-curator, flywheel-promoter
.flywheel/bin/flywheel.py the deterministic CLI (Python standard library only)
.flywheel/config.json thresholds and budgets
.flywheel/memory/ memory entries and the generated MEMORY.md
.flywheel/evals/ the golden-set evals, one folder per skill
.flywheel/templates/ files the installer copies or seeds
openspec/ config.yaml and the five changes that specify the product
docs/README.md the product reference
tests/ unit tests for the CLI (in the download)
LICENSE MIT licenseReference
- docs/README.md - the full product reference: stores, CLI, configuration, guardrails, and status.
- AGENTS.md - layout and conventions for agents working in this repository.
- constitution.md - the rules this repository holds itself to.
Practice for the exam
Building the flywheel shows how memory, skills, and rules fit together in Claude Code. The exam also asks you to choose between designs under time pressure. Practice with CCA-F questions and full mock exams on CertLabPro, or study on your phone with the CertLabPro app for iOS and Android.