Challenge
- As folders multiply, it becomes unclear which folder holds which job and where its tasks are tracked
- Renaming a folder silently breaks absolute paths in MCP servers and Python virtual environments, and past sessions can no longer be resumed
Approach
- Keep the rules in one document, bind each folder to one repository, and track tasks only as GitHub issues
- Make binding, checking, repairing, opening tasks and migration separate skills, with a resident steward agent that uses them on patrol
Outcome
- Renaming a folder or moving tools takes one command, including path repair and carrying session history across
- Every task issue carries a resume command, so you can jump from an issue straight back into the work
Claude Code keeps sessions and settings per folder. Once the number of project folders passes a few dozen, inconsistent names, missing bindings and broken paths pile up quietly, and you notice only when a tool stops working.
So the author wrote the rules down in a single document and built small scripts and skills that read those rules. People decide only whether to start a new job and what kind of job it is; checking and mechanical repair are left to the tools.
The full workflow
| Task | Who | Inputs | Outputs |
|---|---|---|---|
| 1. Bind folder | Author + Bind scripthuman + pbind.py | Refers to Rule document | Binding record |
| 2. Open task | Task scriptpsub_add.py | Binding record | Task issue |
| 3. Health check | Check scriptpcheck.py | Binding record, Refers to Rule document | Findings |
| 4. Dry run | Repair scriptpfix.py | Findings | Dry run |
| 5. Approve + apply | Author + Repair scripthuman + pfix.py | Dry run | Fixed paths |
| 6. Rename folder | Repair scriptpfix.py | Binding record | Moved history |
| 7. Patrol | Steward agent + Check scriptprojects-steward + pcheck.py | Findings, Refers to Rule document | Patrol report |
7 steps · 2 roles · 4 scripts · 16 rules · under version control since 2026-08-13
Keep the rules in one document; the person decides only the type and the go-ahead, and scripts do the checking and repairing.
- Steps 1–2 bind a folder to a GitHub repository and open tasks as issues
- Steps 3–6 check and repair: the check only reads, and every repair shows a dry run before it is applied
- Step 7 is the patrol by a resident steward agent, which uses the same check script and leaves a report
- The person appears only to choose the folder type and to approve a repair
Project folders involved (3)
This workflow does not live in one folder: it runs across projects.
- claude-infra
- The core: rule document, script sources, tests and patrol reports
- ~/.claude (skills, scripts, agents)
- Where it runs: the four skills, the scripts and the steward agent definition
- every project folder (.Project)
- Each working folder holds its binding record and is what gets checked and repaired
Step 1 · Author + Bind script
Bind folderpbind
Choose the folder type and bind it one-to-one to its own repository.
- The person picks one of four types: data, production, output or private
- The result is written to a small record file in the folder, which the status line reads
- Choose the private type and no tool sends anything off the machine from then on
Claude CodeThe type is asked with AskUserQuestion; this choice stays with the person
| Outputs | Binding record |
| Refers to | Rule document |
Step 2 · Task script
Open taskpsub_add
Tasks are recorded only as GitHub issues.
- The title must be something you can mark as done, and the author confirms it first
- The body automatically gets the command that resumes this session
- In a private folder the script refuses and the task stays in a local file
Common misconceptionKeep task state in local notes or a calendar too, and you can no longer tell which one is right
| Inputs | Binding record |
| Outputs | Task issue |
Step 3 · Check script
Health checkpcheck
A read-only check lists drift in binding, naming, MCP configs and virtual environments.
- It returns structured findings and marks which ones can be fixed automatically
- For MCP it checks not only that paths exist but that the module really imports
- For virtual environments it actually runs one command: python may work while pytest is broken
Common misconceptionIf the fetch limit is lower than the total, the oldest items drop out silently and everything looks fine; keep the limit above the total
| Inputs | Binding record |
| Outputs | Findings |
| Refers to | Rule document |
Step 4 · Repair script
Dry runpfix.py
Every repair starts as a dry run that shows exactly what would change.
- Dry run is the default: nothing is written without --apply
- A new MCP path is filled in only when exactly one candidate matches
- Anything needing a human decision (unbound folders, bad names) is listed, not fixed
| Inputs | Findings |
| Outputs | Dry run |
Step 5 · Author + Repair script
Approve + apply--apply
The author reviews the diff, then it is applied and checked again.
- A backup is always taken before writing
- After an MCP fix it runs one more round, because the import probe needs the corrected path first
- MCP changes need a Claude Code restart; virtual-environment fixes work at once
| Inputs | Dry run |
| Outputs | Fixed paths |
Step 6 · Repair script
Rename folderpfix rename
Folders are renamed only through a dedicated command that moves everything tied to them.
- Session history, the binding record and the absolute MCP and virtual-environment paths move together
- Afterwards it recounts past sessions under the new name; zero means failure
- Manual renames once broke four MCP servers, and on another day two virtual environments; that is why this command exists
Common misconceptionMoving the files does not mean the tools still recognise them
| Inputs | Binding record |
| Outputs | Moved history |
Step 7 · Steward agent + Check script
Patrolprojects-steward
A resident steward agent patrols the whole workspace and leaves a report.
- It never rebuilds the check; it calls the check script's functions directly
- Mechanical fixes it makes itself; rule changes and deletions always go back to the author
- The first patrol found 12 of 62 folders unbound, and one inconsistency in the rules themselves
Claude CodeIt is defined as a subagent, called from any session whenever governance comes up
| Inputs | Findings |
| Outputs | Patrol report |
| Refers to | Rule document |
Loops and rework
- Findings remain after applying → step 3: After --apply the check runs again and lists whatever is left
Key points
One place for the rules. Human-readable rules and the machine-readable settings the scripts parse live in the same document, and the rules themselves require that any rule change ships together with the matching code change, so documents and tools never disagree.
Separate checking from repairing. The checker only reads, and returns structured findings on bindings, naming, task-issue format, MCP configs and virtual-environment paths. The fixer shows a dry run by default and applies only after confirmation.
Renames go through the tools. Folders are renamed only with a dedicated command that moves session history, MCP and virtual-environment absolute paths and binding data together. When MCP servers move into a plugin, another skill finds and fixes references to the old tool names and verifies the result.