In the first post I described agent-system, the rules repository that makes Claude Code and Codex work the same way in every project: a new session can pick up where the last one stopped, decisions keep their reasons, and commits are checked for private data. Using it, I kept running into the same few questions: what should happen automatically, which folders the rules should reach, and how to change the rules without breaking the projects that depend on them. This post records how I answered them.
In short, the system got smaller in one place and more modular in another. The hook that ran at the start of every session is gone, and the rules for each kind of project now live in modules that a project loads only after it opts in.
The short version
| First post | Now | |
|---|---|---|
| Decisions recorded | D-1 to D-36 | D-1 to D-48 |
| Regression tests | 103 | 142 |
| Commands | /pickup /wrap /adopt |
plus /new-project |
| Scripts | install, new-project |
plus setup, next-container, release |
| Session start | A hook injected the project state every time | Nothing is read until I type /pickup |
| Project-type rules | One file, profiles/code.md, plus templates/code/ |
A module folder, profiles/code/ |
| Which rules apply | All of RULE.md, in every folder |
The session workflow only in folders that declare a profile |
| Changing the rules | Edits went live as soon as they were saved | Edited in a test copy, released with bin/release |
Seven commits, 12 decisions. The rest of the post goes through the structural changes one at a time, each with a diagram and the reasoning behind it.
How the pieces fit now
The current structure. The global part applies everywhere; a profile module applies only to a project whose AGENTS.md names it on its first line.
The first version assumed every project was a code project: one rules file for code, one template, and a setup script that did everything. But I don’t only write code. Web design, architectural design and slide decks need different files and different wrap-up steps, and folding them into the code rules would have made every rule conditional. So the repository now has two clearly separated parts (D-40):
- The global part is what every session in every folder gets: the shared rules in
RULE.md, the four commands, the scripts, the pre-commit check and the tests.bin/installstill only creates symlinks, and since D-39 it installs no hooks at all. - Profile modules hold everything that depends on the kind of project. Each one is a folder,
profiles/<name>/(D-41):PROFILE.md: the rules. Its first line is the name and a one-line summary, which is what/adoptand/new-projectshow when they ask me to choose.template/: the skeleton that gets copied into a new project. It never overwrites a file that already exists.setup: an optional script for the machine-local steps. For code projects that meansgit initand linking the pre-commit hook.review.md: for code projects, the review rules I hand to Codex.
Adding a kind of project should mean adding one folder, not editing every command. There is only one profile so far, code, and I deliberately stopped there: the parts every profile will share stay inside the code template until a second profile exists. With a single example, any shared layer would only be a guess (D-41).
Session start no longer reads anything
Left: how a session started in the first version. Right: how it starts now. The two struck-out steps were removed by D-39.
In the first version the SessionStart hook was the centerpiece: at the start of every session it read the in-progress block, the last three decisions and the git state, and handed them to the model. Saying “continue” made the agent recap and take the next step.
I removed the hook (D-39) after noticing three things:
- Not every session continues the last one. Often I open a project to ask something unrelated, and the injected state was just noise.
- It cost tokens every time, whether I needed the state or not.
- “Continue” did the same job as
/pickup, only less precisely: it showed the state and also started working.
Now a session starts with nothing but Claude Code’s own git snapshot. If I want to pick up where I stopped, I type /pickup: it reads the Handoff block, the todo list, the decisions it cites and the git state fresh from disk, shows them in at most ten lines, then stops and waits. The two warnings the hook used to give (the block may be stale; AGENTS.md or the notes are too long) moved into /pickup.
The cost is real: the stale-block warning used to appear on its own, and now it only appears if I ask. In the first post I called that warning the only safety net for a forgotten /wrap. It is still there, just behind a command. This is the trade-off I kept making: an automatic step is paid for in every session, a command only when I use it.
One marker decides how much applies
The single check behind everything else. A tried-and-withdrawn second marker is noted at the bottom.
The shared rules load in every folder, including other people’s repositories and scratch folders. I don’t want those folders to fill up with decisions.md and project notes just because I opened Claude there. So the rules now split by one marker: does AGENTS.md start with <!-- profile: NAME -->?
- Yes, an adopted project: all seven sections of
RULE.mdapply, plus the profile and the project’s ownAGENTS.md./pickupgives the full report,/wraprecords decisions, rewrites the Handoff block and updates the documents the profile names. - No, any other folder: only the parts of
RULE.mdthat make sense everywhere apply (sections 4 to 7: execution safety, verification, privacy, writing)./pickupreports the git state and the last five commits, and ends by pointing to/resumefor continuing an old conversation or/adoptfor keeping state./wrapreports in the chat and creates no files (D-43).
/adopt is how a folder moves from the right side to the left: it checks the folder read-only, proposes a migration plan, and changes nothing until I confirm.
This was the one decision that went back and forth. This repository keeps its own notes but declares no profile, so I tried treating docs/project-notes.md as a second marker (D-46). It was released, then withdrawn in the next release (D-47): I preferred the original rule, where only the declaration counts. With one marker I can tell from the first line of AGENTS.md exactly how a folder will be treated. The /resume hint from that change stayed.
Content once, machine-local parts per machine
Two scripts with separate jobs. A new machine only needs the second one.
Before, bin/new-project did everything: it wrote the skeleton files, created ../materials/, ran git init and linked the pre-commit hook. That was fine for a new project, but on a new machine I only need the second half, and running the first half again on an existing project is risky. The distinction that helped was between what a project is (its files, committed once) and what a machine needs (links and folders that git doesn’t carry). So the job is split (D-41):
bin/new-project <dir> <profile>writes the committed content once:AGENTS.mdwith its profile line, theCLAUDE.mdsymlink, the documents underdocs/,README.md,.gitignoreand an emptyprivate-notes.md. It never overwrites a file, and it refuses to run on aP0NN_container folder (D-23).bin/setup <dir>restores what doesn’t come withgit clone: the../materials/folders, the git repository if needed, the pre-commit link, and a check thatprivate-notes.mdis ignored. It writes no content and can be rerun any time. It refuses a folder that declares no profile.
The new /new-project command (D-44) wraps the first script. Typed in the folder that holds all my projects, it asks bin/next-container for the next free number and creates P0NN_NAME/NAME/. The number comes from a script rather than from the model counting folders, because it has to include archived projects and never reuse a number.
Editing the rules without breaking live projects
Every link and every path in the rules points at the live copy, so changes reach it only through bin/release.
The rules repository had become the one project without a safety net. Every symlink and every rule points at ~/agent-system, so a half-finished edit took effect in every project as soon as I saved it. Now there are two checkouts of the same repository (D-45):
~/agent-systemis the live copy onmain. Nothing is edited there.~/agent-system-devis a git worktree ondev, where all the changes are made and committed.
bin/release, run from the dev copy, checks that both copies are clean, runs the full test suite (any failure releases nothing), fast-forwards main, tags it release-N, and runs bin/install. It also lists the new decisions and marks with ! the ones whose impact line says they affect existing projects, so I know which projects to look at. bin/release --rollback checks out the previous tag in the live copy without rewriting history. Pushing stays manual: only main, only when I say so; dev and the tags stay local (D-48).
There have been three releases so far, release-1 to release-3 (release-0 marks the state before the first one). One of them was the withdrawal described above, which is exactly the kind of quick correction this setup is for.
Smaller changes
- Review fixes (D-37). A full review found that commits made in a git worktree ignored the project’s private patterns file, and that Google, GitLab, npm and Stripe tokens, JWTs and passwords inside URLs got through. All fixed, each with a test.
AGENTS.mdholds only project rules (D-38). The template, and two older projects, had copied the session workflow intoAGENTS.md. Because the project file has higher priority, a later change toRULE.mdwould never have taken effect there. The template now just points toRULE.md, and/adoptlists such duplicates and suggests removing them.- “In progress” became “Handoff” (D-42). The block at the top of the project notes has an English heading and English field names now (Updated, Task, Stopped at, Decisions, Waiting on user, Next, Don’t repeat). Old blocks are still read and get converted the next time I
/wrap.
How the decisions evolved
All twelve decisions since the first post, in order. The dashed line links the one addition that was withdrawn.
Looking back at these twelve decisions, they follow a few ideas I hadn’t written down when I started:
- Pay for automation only when it’s used. Something that runs in every session costs something in every session. The hook, the “continue” recap and the injected state all went;
/pickupand/wrapremain commands I type. - Put exact, repeated work in scripts. Container numbers, machine-local setup and releases have to come out the same every time, so they are scripts with tests rather than instructions for the model.
- Keep “which rules apply” to one check. A folder either declares a profile or it doesn’t. The one attempt to add a second marker was withdrawn.
- Separate what a project is from what a machine needs. Committed content is written once; links and folders are restored on each machine.
- Wait for the second case before abstracting. The profile layout exists, but the shared skeleton and profile-specific commands wait until a second profile needs them.
- Treat the rules like any other project. They get a test copy, a test suite, numbered releases and a rollback.
There was also less trial and error than in the first round: one addition withdrawn this time, against two before.
The earlier shortcomings, revisited
| Shortcoming in the first post | Now |
|---|---|
Wrapping up depends on me remembering /wrap |
Unchanged. The stale-block warning now only shows when I type /pickup |
| Profiles depend on the agent reading them | Unchanged; still not imported automatically, to save context |
| Parallel sessions rely on a convention | Unchanged for projects. For the rules repository, the dev copy keeps unfinished edits away from live sessions |
| Secret detection is my own regular expressions | More formats covered (D-37), still regular expressions |
| Only run on one Mac | Unchanged. bin/setup makes a new machine easier, but no second machine has been set up yet |
How the built-in /init interacts is untested |
Unchanged |
| The process has a cost | Lower at session start, since nothing is loaded unless I ask |
Some new ones:
- There is only one profile. The module layout has been tested with exactly one module. The parts every profile will share (the
AGENTS.md, project-notes and decisions skeleton) still live insidecode/template/. - Profile-specific commands and hooks are only a convention so far. The plan is to link them into a project’s
.claude/folder, but the code for that will be written when the first profile needs it. - Release history lives on one machine. The tags aren’t pushed, so a new machine starts counting again from
release-0. /new-projecthasn’t been used for a real project yet. It is covered by tests, and the next step is to try it.
What’s next
- Create a real project with
/new-project. - Remove the copied session workflow from the two older projects’
AGENTS.mdfiles. - Walk through the new-machine steps and the Codex review workflow, which I have postponed so far.
- Define the second profile once I need it, most likely for web or architectural design work.