Working with agents
The daily loop with an AI agent: read cards before changing code, record the why after, catch drift, lint in CI, and split work across parallel agents.
A plan earns its keep when it stays true. The bar for every card is simple: a later agent can change this area without rediscovering the why, the gotchas and the contracts. This page is the routine that keeps a plan at that bar once agents are writing most of the code. It assumes the MCP server is connected; if not, start with Getting started.
The daily loop
Treat the plan as memory shared with every past and future agent, not as docs to skim. Every session runs the same three beats:
- Orient. One
orientcall at session start returns what the project is, the type and status counts, what is drifting and the newest notes across all cards. - Read before you change. Before touching an area, the agent reads the cards that cover it with
search,get_cardortraverse. It starts from the decisions and gotchas earlier sessions recorded instead of from archaeology. - Bring the cards back into line. After the change, the agent updates the cards it made wrong and records the why. That is part of “done”, the same way updating tests is.
Which side moves first depends on the change:
- Behavior changes are plan-first. A new feature, an API contract, a state change or a new surface starts as card edits: new work goes in as
status: planned, you reviewgit diff -- constellation/as the proposal, then the code is brought up to match and the statuses are bumped. - Everything else goes straight to code. Refactors, CSS, renames and dependency bumps change no contract. Do the work, then fix whatever cards it made wrong.
To set this up for a session, ask the agent to call orient first, read the cards that cover the code it is about to touch, and update those cards when it is done.
Notes vs. section edits
Most plan writes are small, and the tools are priced to keep them that way.
append_noteadds one typed note to a card’s memory without touching anything else. The kinds aredecision(a choice and why),gotcha(a non-obvious trap),state(current built reality),deviation(where the code intentionally differs from the card) andverified. Record a correction the moment you learn it.edit_sectionreplaces the content under one##heading and leaves every other byte alone. Use it when the narrative itself is wrong, and always forplan.md, which is never rewritten wholesale.update_cardis the coarse tool: itsbodyandconnectionsreplace the whole value, so send all of it or reach for one of the two above.
A note lands in the card’s frontmatter, where search can find it and list_notes can pull every gotcha or decision in the plan in one call:
---
name: Ticket
status: built
connections:
- DB-TICKETS
code_refs:
- src/types/ticket.ts:Ticket
notes:
- kind: decision
text: requester_email is denormalized onto the ticket so list views avoid a join.
---Notes are a stream, so they accumulate. When a card passes roughly ten notes, or a newer note supersedes an older one, compact it: fold the still-true state notes into the body, keep unresolved gotchas and the newest verified stamp, delete the rest. Git keeps every deleted line.
Verification stamps and drift
A card’s status is a claim: planned → building → built → verified. Constellation makes the last two re-checkable instead of taken on faith.
- Bound code. A card is bound to the code of the FILE cards it connects to (their
path:) plus its owncode_refs. - Drift follows git. A card is stale when its bound code has commits newer than the card’s own last commit. Commit cards together with the code they describe and they never show as drifted.
set_verifiedstampsverified_shaandverified_atand setsstatus: verifiedafter an agent has actually checked a card against committed code. That sha becomes the baseline drift is measured from. A re-verification sweep is one call withhandles: [...].stale_reportlists the cards whose bound code moved on without them, with the files that changed.check_syncrolls that and the plan-wide state into one verdict: in sync, drifted, dirty or never synced.
Uncommitted changes to bound code always count, so a stale report on a dirty tree is work in progress, not drift to fix. check_sync is advisory: it reports and never blocks. Treat code that changed without its cards re-verified as not done yet. The viewer’s Overview page shows the same verdict as a Code drift panel.
Lint in CI
constellation lint exits 1 when the plan has errors and 0 when it has none (it exits 2 if it finds no plan at all), so any CI system can run it as a step.
- Errors fail the build. They mean a broken graph: a filename that is not a valid handle, an unknown type prefix, a duplicate handle, invalid YAML, or a
connections:entry or frontmatter reference that resolves to no card. - Warnings never do. A card in the wrong folder, a schema violation, an unknown field or a dangling
[[link]]in prose are quality signals to clean up, not reasons to block a merge.
Keeping the plan in sync on branches and PRs
Because the plan is files, a plan change is a commit. It rides the same branch and the same PR as the code it describes, and reviewers see both in one diff.
- Review the plan diff.
git diff -- constellation/is the plan diff;diff_plangives an agent the same thing per card, with the frontmatter keys that changed. For plan-first work, approving the plan diff is the gate before an agent writes the code. - Track features on their branch. A coherent slice of work is a FEATURE card connected to every card it adds or touches. Set
branch:while it is in flight, movestatusthroughbuildingtobuiltwhen it merges, and setpr:as provenance. Shipped features stay as the record of why the system grew. - Mark the sync point. After reconciling code with the plan,
set_sync_pointrecords the commit inconstellation/.sync.json.diff_planandassembleuse it as their default base. Commit the plan first, so the marker points at a commit that contains it.
--- name: Auto-assignment of new tickets status: building release: RELEASE-V1-1-0 change: feature branch: feature/auto-assign connections: - JOB-AUTO-ASSIGN - API-TICKETS - DB-TICKETS - STATE-TICKET ---
Work packages for parallel agents
When a change spans several areas, assemble turns a set of cards into work packages you can hand out. Give it seed handles, or omit them to assemble everything that changed in the plan since the sync marker. It returns:
- File-disjoint units. The seeds are split so no two units share a bound file, which means one sub-agent per unit cannot collide on a file.
- A suggested build order, a heuristic from data to contracts to surfaces.
- An index, not a dump. By default it returns summaries and bound paths with no card bodies; each agent pulls the three or four cards its unit actually needs with
get_card. Passhydration: "full"to get the bodies inline.
In practice, ask the agent to assemble the plan changes since the sync point, give each unit to its own sub-agent in the suggested order, and check each unit against its cards before reporting back.
Two rules keep parallel work safe. Assign each card to exactly one agent: two agents calling update_card on the same card race, and the later write wins. And verify the agents’ work yourself against the cards it was meant to satisfy before calling it done.
Auditing the plan
Every so often, or before a release, run the audit_plan prompt (in Claude Code, /mcp__constellation__audit_plan). It reconciles the plan with the codebase: missing, stale and orphaned cards, dangling references, and statuses checked against the real code. It ends with what is missing, stale or orphaned and a short, prioritized list of recommendations, and leaves structural cleanups for you to decide. For a quick structural pass without a full audit, check_integrity runs the lint checks plus orphans, the cards with no connections at all.
What belongs in a card
Put in cards what the code cannot say, and link to the code for everything else.
| In a card | In the code |
|---|---|
| Why it works this way, and the alternatives you rejected | Function signatures and types |
| Gotchas someone already hit | Table DDL and migrations |
| Contracts that cross a boundary: who calls what, with which shape | Implementation details inside one module |
| Current state: what is built, planned or in flight | A changelog (that is git) |
| Cross-cutting rules every change must respect | Anything a competent reader gets from reading the file |
- Smaller is better. The best plan is the smallest one that still passes the bar. Create FILE cards for load-bearing files such as entry points, route tables and core modules, not for every file in the repo.
- No index cards. A card that lists other cards (every DECISION, a table of contents) is stale by the next card.
list_cards,searchand the viewer produce those views live. - One DECISION card per topic. When a decision changes, rewrite the card to state the current choice; the abandoned approach becomes a line under Alternatives. A choice local to one card is a
decisionnote instead. - Present tense. A body should read in about a minute and describe the system as it is now. History lives in git and in
plan_log. - Session state is not a card. What is in flight this week (open tasks, worktrees, questions for you) belongs in working memory, a gitignored
.constellation/folder beside the plan that theworking_*tools manage. Cards say what the system is; working memory says what you are doing about it.