context-update — Canonical Playbook
Synchronize docs/CONTEXT.md, docs/STATE.md, and docs/CHANGELOG.md with the reality of what was built in a completed phase.
This document is the single source of truth for the context-update workflow. Runtime wrappers point here.
Input
- Target phase number (e.g.
01).
Required reads
docs/PHASE_XX.md— focus on the Contracts sectiondocs/CONTEXT.md— current contracts (models, endpoints, schema, env vars)docs/STATE.md— current phase statusesdocs/CHANGELOG.md
Procedure
1. Confirm the phase is ready
Check docs/STATE.md:
⏳ pending→ warn: "Phase XX has not started yet. Are you sure gate checks passed?" and wait.✅ done→ warn: "Phase XX is already marked done. Re-running will overwrite — confirm?" and wait.🔄 in-progressor gate just passed → proceed.
2. Extract contracts from docs/PHASE_XX.md
From the Contracts section, extract:
- New DB tables / columns
- New API endpoints
- New TypeScript types / Pinia stores
- New env vars (key names only)
If every Contracts subsection is None: no version bump needed. Skip to step 6 (STATE.md update).
3. Determine if contracts changed
- If every Contracts subsection is
None: no contracts changed → skip steps 4 and 5; go directly to step 6 (STATE.md update). - Otherwise: contracts changed → proceed with steps 4 and 5.
4. Update docs/CONTEXT.md
Surgical edits:
- Set
phase_completedto the phase number (e.g."01"). - Set
phase_in_progressto next phase number ornull. - Append to
core_models— do NOT remove existing. - Append to
endpoints_active— do NOT remove existing. - Append to
db_schema.tables. - Update
db_schema.current_headto the latest alembic revision name (if backend-bearing). - Append to
env_config.keys. - Update
notes: one sentence, "Phase XX complete. [What was added]."
5. Prepend to docs/CHANGELOG.md (only if contracts changed)
```markdown
[YYYY-MM-DD] — Phase [XX] complete
Type: phase-completion Author: AI (context-update) Triggered by: PHASE_[XX] gate passed and committed
Changes
- [what was built / added]
Affected Phases
- None (additive change)
Contract Updates
- [new tables, endpoints, env vars]
Notes
[Notable decisions made during this phase.] ```
If no contracts changed: no CHANGELOG entry.
6. Update docs/STATE.md
- Change the
PHASE_[XX]row status to✅ done. - Change its Gate column from
⬜to✅.
7. Report
```
context-update complete — PHASE_[XX]
CONTEXT.md: contracts appended / no change — [reason] STATE.md: PHASE_[XX] marked ✅ done CHANGELOG.md: entry added / no entry needed
Next: /phase-init [XX+1] to scaffold the next phase. ```
Rules
- Never remove existing entries from CONTEXT.md arrays — append only.
- If the Contracts section is incomplete, stop and ask the architect to fill it in.
- Do not commit.
Done when
CONTEXT.mdmatches what was built.STATE.mdmarks the phase done.CHANGELOG.mdreflects the bump (if any).