Skip to content

Commit eaefd35

Browse files
committed
[Maintain] Simplify MAINTAIN protocol from 4 phases to 2
Problems with the old protocol: - 4 phases x 3-way consultation = 12 consultation calls per run - Runs stalled (0006 never completed past audit) - Last completed run was 4 months ago - Audit findings went stale before clean phase ran Changes: - Collapse audit/clean/sync/verify into single "maintain" phase - Keep one 3-way review during maintain, one before PR (review phase) - Fix tool commands for pnpm monorepo (was npm) - Simplify maintenance run template - Remove per-phase prompts (audit.md, clean.md, sync.md, verify.md) - Add consolidated maintain.md and review.md prompts - Update both codev/ and codev-skeleton/ - Protocol version bumped to 3.0.0
1 parent 3c36441 commit eaefd35

20 files changed

Lines changed: 628 additions & 1923 deletions

File tree

codev-skeleton/protocols/maintain/builder-prompt.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ You are executing the MAINTAIN protocol to clean up and synchronize the codebase
77
You are running in SOFT mode. This means:
88
- You follow the MAINTAIN protocol yourself (no porch orchestration)
99
- The architect monitors your work and verifies you're adhering to the protocol
10-
- Work through each phase methodically
10+
- Work through each step methodically
1111
{{/if}}
1212

1313
{{#if mode_strict}}
@@ -20,36 +20,37 @@ You are running in STRICT mode. This means:
2020
### ABSOLUTE RESTRICTIONS (STRICT MODE)
2121
- **NEVER edit `status.yaml` directly** — only porch commands may modify project state
2222
- **NEVER call `porch approve` without explicit human approval** — only run it after the architect says to
23-
- **NEVER skip the 3-way review** — always follow porch next → porch done cycle
2423
{{/if}}
2524

2625
## Protocol
2726
Follow the MAINTAIN protocol: `codev/protocols/maintain/protocol.md`
2827

2928
## MAINTAIN Overview
30-
The MAINTAIN protocol handles codebase hygiene:
3129

32-
1. **Audit Phase**: Scan for dead code, unused dependencies, stale docs
33-
2. **Clean Phase**: Remove identified cruft, verify build
34-
3. **Sync Phase**: Update documentation (arch.md, lessons-learned.md, CLAUDE.md)
35-
4. **Verify Phase**: Run full test suite, confirm health
30+
Two phases:
31+
1. **Maintain**: Single pass — audit findings, clean dead code, sync docs, verify build
32+
2. **Review**: Create PR with 3-way consultation
3633

3734
## Key Rules
3835
- Use soft deletion (move to `codev/maintain/.trash/`)
39-
- Always verify build passes after removals
36+
- Verify build passes after each removal (`cd packages/codev && pnpm build && pnpm test`)
4037
- Update documentation to match current architecture
4138
- Don't remove anything actively used
39+
- One removal at a time — commit after each
40+
- Document every deletion with justification
41+
- Never use `git add -A` or `git add .`
4242

4343
## Handling Flaky Tests
4444

4545
If you encounter **pre-existing flaky tests** (intermittent failures unrelated to your changes):
4646
1. **DO NOT** edit `status.yaml` to bypass checks
4747
2. **DO NOT** skip porch checks or use any workaround to avoid the failure
4848
3. **DO** mark the test as skipped with a clear annotation (e.g., `it.skip('...') // FLAKY: skipped pending investigation`)
49-
4. **DO** document each skipped flaky test in your review under a `## Flaky Tests` section
49+
4. **DO** document each skipped flaky test in your maintenance run file
5050
5. Commit the skip and continue with your work
5151

5252
## Getting Started
5353
1. Read the MAINTAIN protocol document
54-
2. Start with the Audit phase
55-
3. Document all changes made
54+
2. Run `porch next` to get your first task
55+
3. Work through audit → clean → sync → verify in a single pass
56+
4. Document everything in the maintenance run file

codev-skeleton/protocols/maintain/prompts/audit.md

Lines changed: 0 additions & 111 deletions
This file was deleted.

codev-skeleton/protocols/maintain/prompts/clean.md

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# MAINTAIN Phase Prompt
2+
3+
You are executing the **maintain** phase — a single pass covering audit, cleanup, and doc sync.
4+
5+
## Context
6+
7+
- **Current State**: {{current_state}}
8+
9+
## Step 1: Determine Scope
10+
11+
```bash
12+
ls codev/maintain/
13+
```
14+
15+
Find the last run number and its base commit. Then see what changed:
16+
17+
```bash
18+
git log --oneline <base-commit>..HEAD
19+
```
20+
21+
Create your maintenance run file: `codev/maintain/NNNN.md` (next number in sequence).
22+
23+
## Step 2: Audit
24+
25+
Identify dead code, unused dependencies, and stale documentation. Don't fix yet — catalog first.
26+
27+
```bash
28+
# Dead exports
29+
npx ts-prune 2>/dev/null || echo "ts-prune not available"
30+
31+
# Unused dependencies
32+
npx depcheck 2>/dev/null || echo "depcheck not available"
33+
34+
# Stale arch.md references
35+
grep -oE '[a-zA-Z]+/[a-zA-Z/]+\.[a-z]+' codev/resources/arch.md | sort -u | while read f; do
36+
[ -e "$f" ] || echo "Missing: $f"
37+
done
38+
```
39+
40+
Record all findings in the maintenance run file.
41+
42+
## Step 3: Clean
43+
44+
For each audit finding:
45+
1. Verify it's truly unused (grep the codebase)
46+
2. Remove with `git rm` (tracked) or move to `codev/maintain/.trash/$(date +%Y-%m-%d)/` (untracked)
47+
3. Build and test: `cd packages/codev && pnpm build && pnpm test`
48+
4. Commit: `git add <specific-files> && git commit -m "[Maintain] Remove unused X"`
49+
50+
One removal at a time. Verify after each. Never use `git add -A`.
51+
52+
## Step 4: Sync Documentation
53+
54+
**arch.md**: Read `codev/resources/arch.md`, compare with actual codebase. Update directory structure, component descriptions, key files. Remove references to deleted code. Add new components. Explain HOW things work, not just WHAT.
55+
56+
**lessons-learned.md**: Scan `codev/reviews/` for new reviews since the base commit. Extract actionable, durable, general lessons.
57+
58+
**CLAUDE.md / AGENTS.md**: `diff CLAUDE.md AGENTS.md` — they must be identical. Update the stale one.
59+
60+
**Pruning**: Remove obsolete content. Document every deletion with justification (OBSOLETE, DUPLICATIVE, MOVED, VERBOSE). When in doubt, keep.
61+
62+
Commit documentation changes:
63+
```bash
64+
git add codev/resources/arch.md codev/resources/lessons-learned.md
65+
git commit -m "[Maintain] Update arch.md and lessons-learned.md"
66+
```
67+
68+
## Step 5: Final Checks
69+
70+
```bash
71+
cd packages/codev && pnpm build && pnpm test
72+
```
73+
74+
Both must pass. Update the maintenance run file with a summary of everything done.
75+
76+
## Signals
77+
78+
When all work is complete and build/tests pass:
79+
80+
```
81+
<signal>PHASE_COMPLETE</signal>
82+
```
83+
84+
If blocked:
85+
86+
```
87+
<signal>BLOCKED:reason</signal>
88+
```

0 commit comments

Comments
 (0)