@theglitchking/persistent-planning 3.5.0 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.documentation/INDEX.md +6 -5
  4. package/.documentation/knowledge-base/facts/INDEX.md +59 -0
  5. package/.documentation/knowledge-base/facts/babel-fish-hook-adds-untracked-map.md +56 -0
  6. package/.documentation/knowledge-base/facts/claude-code-grep-v-exit-status.md +55 -0
  7. package/.documentation/knowledge-base/facts/git-rm-cached-moved-path-drops-staged.md +56 -0
  8. package/.documentation/knowledge-base/incidents/INDEX.md +17 -0
  9. package/.documentation/knowledge-base/symptoms/INDEX.md +17 -0
  10. package/.documentation/procedures/INDEX.md +3 -3
  11. package/.documentation/procedures/REGISTRY.md +3 -3
  12. package/.documentation/procedures/plan-completion-and-archive.md +11 -5
  13. package/.documentation/standards/INDEX.md +3 -3
  14. package/.documentation/standards/REGISTRY.md +3 -3
  15. package/.documentation/standards/mandatory-closing-phases.md +43 -2
  16. package/.documentation/troubleshooting/INDEX.md +4 -3
  17. package/.documentation/troubleshooting/REGISTRY.md +6 -4
  18. package/.documentation/troubleshooting/docs-closer-missing-hewtd-steps.md +57 -0
  19. package/.documentation/troubleshooting/stale-skill-dir-drift.md +4 -2
  20. package/CHANGELOG.md +62 -0
  21. package/commands/start-planning.md +12 -0
  22. package/package.json +1 -1
  23. package/scripts/archive-plan.sh +20 -6
  24. package/scripts/init-atom.sh +2 -0
  25. package/scripts/init-phase.sh +42 -9
  26. package/scripts/init-planning.sh +60 -4
  27. package/scripts/init-task.sh +2 -0
  28. package/scripts/lib/planning.sh +61 -0
  29. package/skills/persistent-planning/SKILL.md +16 -3
  30. package/templates/git-workflow-section.md +11 -0
  31. package/templates/lg/phase.md +12 -2
  32. package/templates/rules/persistent-planning.md +35 -0
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: A plan's docs step has no hit-em-with-the-docs steps
3
+ tier: guide
4
+ domains:
5
+ - troubleshooting
6
+ audience:
7
+ - developers
8
+ tags: []
9
+ status: active
10
+ last_updated: '2026-10-23'
11
+ version: 1.0.0
12
+ purpose: Why a new plan in a hit-em-with-the-docs project got the generic docs step, and how to fix it.
13
+ estimated_read_time: 2 minutes
14
+ word_count: 224
15
+ last_validated: '2026-10-23'
16
+ backlinks: []
17
+ ---
18
+
19
+ # A plan's docs step has no hit-em-with-the-docs steps
20
+
21
+ ## Symptom
22
+
23
+ The project uses hit-em-with-the-docs, but a new plan's last step is the generic
24
+ one. sm: `Phase 7: Documentation pass -- create/update/deprecate as many docs as
25
+ needed to capture what was done…`. lg: the docs closer has no `hewtd audit`,
26
+ gotcha or KB-article atoms. The full hit-em-with-the-docs pass wording is missing.
27
+
28
+ ## Cause
29
+
30
+ The init scripts choose the wording once, when the plan is written. They use the
31
+ hewtd variant only when the **project** has a `.documentation/` tree or
32
+ `.claude/hit-em-with-the-docs.json`. Common reasons it wasn't chosen:
33
+
34
+ - **hewtd is only installed for the machine** (e.g. a marketplace install).
35
+ That's deliberate: otherwise every repo you plan in would get hewtd steps.
36
+ - **The plan predates the docs tree.** The project adopted hewtd after the plan
37
+ was written. Existing plans are never rewritten.
38
+ - **`CLAUDE_PROJECT_DIR` points somewhere else.** The scripts look in
39
+ `CLAUDE_PROJECT_DIR`, falling back to the current directory, not the git root.
40
+
41
+ ## Fix
42
+
43
+ 1. Check what the scripts see:
44
+ ```bash
45
+ ls -d "${CLAUDE_PROJECT_DIR:-$PWD}/.documentation" \
46
+ "${CLAUDE_PROJECT_DIR:-$PWD}/.claude/hit-em-with-the-docs.json"
47
+ ```
48
+ 2. If neither exists, set the project up with hit-em-with-the-docs (that creates
49
+ `.documentation/`), then start the plan again.
50
+ 3. For a plan that already exists, edit its last step by hand. sm: the Phase 7
51
+ line. lg: the docs closer's line in `phase.md` and its atoms. Or re-create it with
52
+ `PLANNING_FORCE=1` if nothing in it is worth keeping. Keep the lg slug
53
+ `documentation-pass-create-update-deprecate-docs`, because the completion gate
54
+ depends on it.
55
+
56
+ See [mandatory closing phases](../standards/mandatory-closing-phases.md) for the
57
+ two variants.
@@ -33,11 +33,13 @@ A generated `task_plan.md` ends at Phase 4. A correct one ends:
33
33
 
34
34
  ```
35
35
  - [ ] Phase 5: Cleanup -- remove junk and unused code this work created: scratch/test scripts, debug files, probe logging, one-off test functions, commented-out code, dead code from abandoned approaches (MANDATORY)
36
- - [ ] Phase 6: Validate success through comprehensive testing (MANDATORY)
36
+ - [ ] Phase 6: Validate success through comprehensive testing -- we need to validate success thoroughly through comprehensive testing of our changes (MANDATORY)
37
37
  - [ ] Phase 7: Documentation pass -- create/update/deprecate as many docs as needed to capture what was done, where it lives, how to troubleshoot it, etc. etc.. etc.. (MANDATORY)
38
38
  ```
39
39
 
40
- and carries an `## On Completion` section naming `/plan-status` and `/archive-plan`.
40
+ (In a project that uses hit-em-with-the-docs, Phase 7 reads as a full hit-em-with-the-docs pass instead —
41
+ see [mandatory closing phases](../standards/mandatory-closing-phases.md).) It also
42
+ carries an `## On Completion` section naming `/plan-status` and `/archive-plan`.
41
43
 
42
44
  ## Cause
43
45
 
package/CHANGELOG.md CHANGED
@@ -2,6 +2,68 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [3.6.1] - 2026-10-23
6
+
7
+ ### Fixed — archived plans stayed tracked in git (#26)
8
+
9
+ `archive-plan.sh` moved tracked plans with `git mv`, so they stayed tracked
10
+ inside the gitignored `.planning/.archive/`, because ignore rules never apply to
11
+ tracked files. It now moves the plan and untracks it (`git rm -r --cached`).
12
+ The files stay on disk and the next commit shows the plan as deleted. A plan
13
+ with staged changes stays tracked with a warning rather than losing content
14
+ only the index holds. Repos with plans archived earlier:
15
+ `git rm -r --cached .planning/.archive`.
16
+
17
+ ## [3.6.0] - 2026-10-23
18
+
19
+ ### Added — a full hit-em-with-the-docs pass as the last step, when the project uses it
20
+
21
+ When the project has `.documentation/` or `.claude/hit-em-with-the-docs.json`, the
22
+ plan's last step reads "Documentation pass -- a full hit-em-with-the-docs pass to
23
+ create/update/deprecate as many docs as needed to capture all our changes: new
24
+ procedures, tools, troubleshooting steps, gotchas, KB articles, etc. Never include
25
+ secrets or passwords". lg's docs closer also gets hewtd atoms: integrate/archive,
26
+ gotchas as KB facts, KB articles, never secrets, `maintain --quick` + `audit`.
27
+ A machine-wide hewtd install does not count.
28
+
29
+ - **Fixed:** lg plans in projects without hewtd no longer get the unconditional
30
+ `npx hewtd archive` / `npx hewtd audit` atoms.
31
+ - Every variant's note now says to capture procedures, tools, troubleshooting,
32
+ gotchas and KB articles, and never secrets or passwords.
33
+ - The docs step asks to be filled in when the plan is written, naming each doc
34
+ the work creates, changes or makes stale (lg: the closer's first atom). In a
35
+ behaviour test, the docs closer was otherwise left generic.
36
+ - Projects without hewtd: the sm Phase 7 line and the lg closer line are
37
+ byte-identical to before. The slug is unchanged.
38
+
39
+ ### Changed — the validation closer asks for the tests when the plan is written
40
+
41
+ The validate step now reads "we need to validate success thoroughly through
42
+ comprehensive testing of our changes". It also tells Claude to write the
43
+ concrete checks into the plan up front, without being asked: unit,
44
+ integration/end-to-end, regression, edge cases and failure paths, and the full
45
+ suite. sm: Phase 6 line and note. lg: `phase.md` note plus two new leading atoms
46
+ on the validation task. The `persistent-planning.md` rule and SKILL.md carry it
47
+ too. Titles and slugs are unchanged, so existing plans and the completion gate
48
+ are unaffected.
49
+
50
+ ### Added — init scripts seed `.claude/rules/`
51
+
52
+ Every init script (`init-planning.sh`, `init-phase.sh`, `init-task.sh`,
53
+ `init-atom.sh`) copies each `templates/rules/*.md` into the project's
54
+ `.claude/rules/` when that file is absent, so Claude Code loads the planning
55
+ workflow every session instead of only when the skill triggers. Ships one rule,
56
+ `persistent-planning.md`. A rule is written once and never overwritten — not even
57
+ under `PLANNING_FORCE` — so a repo's edits stick; delete it and the next init
58
+ restores it. Adding a rule is adding a file to `templates/rules/`.
59
+
60
+ The same step adds a **Persistent plans** section of hard git requirements — sync
61
+ `main`, cut a branch, implement through to completion, commit at the end of each
62
+ phase, finish with a single PR. It is appended to the repo's existing git workflow
63
+ rule (any `.claude/rules/` file named like `git-workflow.md` or `gitflow.md`,
64
+ including babel-fish's) or, if there is none, creates `git-workflow.md`. A marker
65
+ comment keeps it to one copy.
66
+
5
67
  ## [3.5.0] - 2026-09-26
6
68
 
7
69
  ### Added — a mandatory cleanup closer at the end of every phase (#20)
@@ -100,6 +100,18 @@ bash ~/.claude/skills/persistent-planning/scripts/init-planning.sh "<name>"
100
100
 
101
101
  Add tasks under a phase with `/start-task "<name>" --parent <phase-slug>`.
102
102
 
103
+ ### Both modes
104
+ In a project that uses hit-em-with-the-docs (it has `.documentation/`), the last step
105
+ is worded as a full hit-em-with-the-docs pass: capture all changes, including procedures,
106
+ tools, troubleshooting, gotchas and KB articles, and never secrets.
107
+
108
+ `.claude/rules/persistent-planning.md` is added if the project does not already have
109
+ it. It is never overwritten, so edit it freely.
110
+
111
+ A "Persistent plans" git section (sync main, branch, commit per phase, one PR) is
112
+ appended once to the project's existing git workflow rule, or `.claude/rules/git-workflow.md`
113
+ is created to hold it.
114
+
103
115
  ## Slug conversion
104
116
 
105
117
  Names are converted to URL-friendly slugs:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theglitchking/persistent-planning",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "description": "Persistent markdown-based planning with task directories, progress tracking, and context engineering for multi-step Claude Code workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,8 +12,8 @@
12
12
  # 1. Refuses unless the plan is complete (every checkbox checked, or the
13
13
  # top-level artifact declares `status: done`) -- override with --force.
14
14
  # 2. Ensures .planning/.archive/ exists and is gitignored.
15
- # 3. Moves .planning/<slug>/ to .planning/.archive/<slug>/ (git mv when the
16
- # plan is tracked, so history follows it).
15
+ # 3. Moves .planning/<slug>/ to .planning/.archive/<slug>/. A tracked plan is
16
+ # also removed from git's index (files stay on disk): archives are local.
17
17
  # 4. Stamps the plan's top-level artifact with status: archived + archived_on.
18
18
  #
19
19
  # Nothing is ever deleted. Restore by moving the directory back out.
@@ -111,18 +111,32 @@ archive_one() {
111
111
  fi
112
112
 
113
113
  if [[ $DRY_RUN -eq 1 ]]; then
114
- planning_log "[dry-run] would archive .planning/${slug}/ -> .planning/.archive/${slug}/"
114
+ planning_log "[dry-run] would archive .planning/${slug}/ -> .planning/.archive/${slug}/ (untracked from git if tracked)"
115
115
  return 0
116
116
  fi
117
117
 
118
118
  ensure_gitignored
119
119
  mkdir -p "$ARCHIVE"
120
120
 
121
+ local tracked=0 staged=0
121
122
  if git -C "$ROOT" rev-parse --git-dir >/dev/null 2>&1 \
122
123
  && [[ -n "$(git -C "$ROOT" ls-files ".planning/${slug}" 2>/dev/null)" ]]; then
123
- git -C "$ROOT" mv ".planning/${slug}" ".planning/.archive/${slug}"
124
- else
125
- mv "$src" "$dest"
124
+ tracked=1
125
+ git -C "$ROOT" diff --cached --quiet -- ".planning/${slug}" 2>/dev/null || staged=1
126
+ fi
127
+
128
+ mv "$src" "$dest"
129
+
130
+ # A tracked plan leaves the index: archived plans are local history (issue #26).
131
+ # git mv kept them tracked inside the gitignored .archive/, since ignore rules
132
+ # never apply to tracked files. Staged changes are checked first, because once
133
+ # the files have moved git rm --cached no longer refuses and would drop them.
134
+ if [[ $tracked -eq 1 && $staged -eq 1 ]]; then
135
+ planning_warn "Archived on disk, but git still tracks .planning/${slug}/ (it has staged changes)."
136
+ echo " Commit or unstage them, then untrack with: git rm -r --cached .planning/${slug}" >&2
137
+ elif [[ $tracked -eq 1 ]]; then
138
+ git -C "$ROOT" rm -r -q --cached ".planning/${slug}" >/dev/null 2>&1 \
139
+ || planning_warn "Archived on disk, but could not untrack .planning/${slug}/: git rm -r --cached .planning/${slug}"
126
140
  fi
127
141
 
128
142
  stamp_archived "$(plan_root_artifact "$dest")"
@@ -137,6 +137,8 @@ planning_insert_list_item \
137
137
  "## Atoms" \
138
138
  "- [ ] **${ATOM_NAME}** (\`atoms/${ATOM_SLUG}.md\`, sequence: ${NEXT_SEQUENCE})"
139
139
 
140
+ planning_seed_rules "${ROOT}"
141
+
140
142
  echo ""
141
143
  planning_ok "Atom '${ATOM_NAME}' ready"
142
144
  echo ""
@@ -107,6 +107,41 @@ fi
107
107
  # Create phase directory
108
108
  mkdir -p "$PHASE_DIR"
109
109
 
110
+ # The docs closer's wording depends on whether this project uses hit-em-with-the-docs.
111
+ # Its slug never changes: the completion gate and existing plans key on it.
112
+ # Both variants open by asking the planner to name the docs — the generic atoms alone
113
+ # left the closer unfilled while the validation closer, which asks, got filled.
114
+ DOCS_PLAN_ATOM="As this phase's tasks are written, add an atom here for each doc they create, change or make stale, naming the file — check the existing docs for ones this work makes wrong"
115
+ if planning_uses_hewtd "$ROOT"; then
116
+ DOCS_CLOSER="Documentation pass — a full hit-em-with-the-docs pass to create/update/deprecate as many docs as needed to capture all our changes: new procedures, tools, troubleshooting steps, gotchas, KB articles, etc. Never include secrets or passwords"
117
+ DOCS_TITLE="Documentation pass — full hit-em-with-the-docs pass"
118
+ DOCS_ATOMS=(
119
+ "$DOCS_PLAN_ATOM"
120
+ "Full hit-em-with-the-docs pass: create/update/deprecate as many docs as needed to capture all our changes"
121
+ "Create docs with \`npx hewtd integrate <file> -a\`; retire superseded ones with \`npx hewtd archive <file>\` — never by deleting"
122
+ "Capture every new procedure and tool: what it is, where it lives, how to run it"
123
+ "Add a troubleshooting entry for the symptom someone will actually search for"
124
+ "Record each gotcha (a non-obvious failure with an observed fix) as a knowledge-base fact tagged \`gotcha\`, with an \`## Instead\` section"
125
+ "Write KB articles for anything operational under \`.documentation/knowledge-base/\`"
126
+ "Update every existing doc this phase made wrong — a stale doc is worse than a missing one"
127
+ "Never include secrets, passwords, tokens or keys in any doc"
128
+ "Run \`npx hewtd maintain --quick\` and \`npx hewtd audit\`; resolve every error"
129
+ "Never hand-edit INDEX.md or REGISTRY.md — they are generated"
130
+ )
131
+ else
132
+ DOCS_CLOSER="Documentation pass — create/update/deprecate as many docs as needed to capture what was done, where it lives, how to troubleshoot it, etc. etc.. etc.."
133
+ DOCS_TITLE="Documentation pass — create/update/deprecate docs"
134
+ DOCS_ATOMS=(
135
+ "$DOCS_PLAN_ATOM"
136
+ "Create docs for what was built: what it is, where it lives, how it works"
137
+ "Capture new procedures, tools, troubleshooting steps and gotchas — add a troubleshooting entry for the symptom someone will actually search for"
138
+ "Update every existing doc this phase made wrong — a stale doc is worse than a missing one"
139
+ "Retire superseded docs rather than leaving them wrong"
140
+ "Never include secrets, passwords, tokens or keys in any doc"
141
+ "If hit-em-with-the-docs is installed you MUST use it: \`npx hewtd integrate <file> -a\` to create, \`npx hewtd archive <file>\` to retire, \`npx hewtd maintain --quick\` to regenerate indexes"
142
+ )
143
+ fi
144
+
110
145
  # Render phase.md
111
146
  planning_render_and_log \
112
147
  "${TEMPLATE_DIR}/phase.md" \
@@ -114,7 +149,8 @@ planning_render_and_log \
114
149
  "phase.md at ${PHASE_DIR}/phase.md" \
115
150
  "PHASE_TITLE_PLACEHOLDER=${PHASE_NAME}" \
116
151
  "PHASE_SLUG_PLACEHOLDER=${PHASE_SLUG}" \
117
- "PHASE_DATE_PLACEHOLDER=${TODAY}"
152
+ "PHASE_DATE_PLACEHOLDER=${TODAY}" \
153
+ "DOCS_CLOSER_PLACEHOLDER=${DOCS_CLOSER}"
118
154
 
119
155
  # Render notes.md (scoped to the phase)
120
156
  planning_render_and_log \
@@ -175,6 +211,8 @@ scaffold_closer \
175
211
  scaffold_closer \
176
212
  "validate-success-through-comprehensive-testing" \
177
213
  "Validate success through comprehensive testing" \
214
+ "We need to validate success thoroughly through comprehensive testing of our changes: as this phase's tasks are written, add an atom here for each check they need" \
215
+ "Cover every kind that applies: unit tests for new and changed logic, integration and end-to-end runs through the real entry points, edge cases and failure paths" \
178
216
  "Prove every claim this phase makes with a test that fails if it breaks" \
179
217
  "Test the invariant after mutation, not the shape of a freshly rendered template" \
180
218
  "Cover the failure mode that prompted the work, not just the happy path" \
@@ -182,17 +220,12 @@ scaffold_closer \
182
220
 
183
221
  scaffold_closer \
184
222
  "documentation-pass-create-update-deprecate-docs" \
185
- "Documentation pass — create/update/deprecate docs" \
186
- "Create docs for what was built: what it is, where it lives, how it works" \
187
- "Add a troubleshooting entry for the symptom someone will actually search for" \
188
- "Update every existing doc this phase made wrong — a stale doc is worse than a missing one" \
189
- "Retire superseded docs with \`npx hewtd archive <file>\` — never by deleting" \
190
- "If hit-em-with-the-docs is installed you MUST use it: \`npx hewtd integrate <file> -a\` to create, \`npx hewtd maintain --quick\` to regenerate indexes" \
191
- "Run \`npx hewtd audit\` and resolve every error" \
192
- "Never hand-edit INDEX.md or REGISTRY.md — they are generated"
223
+ "$DOCS_TITLE" \
224
+ "${DOCS_ATOMS[@]}"
193
225
 
194
226
  # Only completed plans are local history — see planning_ensure_archive_gitignored.
195
227
  planning_ensure_archive_gitignored "${ROOT}"
228
+ planning_seed_rules "${ROOT}"
196
229
 
197
230
  echo ""
198
231
  planning_ok "Phase '${PHASE_NAME}' ready at .planning/${PHASE_SLUG}/"
@@ -15,7 +15,8 @@
15
15
  # 2. Creates task_plan.md with templates
16
16
  # 3. Creates notes.md with templates
17
17
  # 4. Adds .planning/ to .gitignore (optional)
18
- # 5. Confirms creation and provides next steps
18
+ # 5. Copies templates/rules/*.md into .claude/rules/ (only files not already there)
19
+ # 6. Confirms creation and provides next steps
19
20
  #
20
21
  # Multiple tasks example:
21
22
  # /start-planning "Refactor auth" -> .planning/refactor-auth/
@@ -65,6 +66,14 @@ PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
65
66
  PLANNING_DIR="${PROJECT_ROOT}/.planning"
66
67
  TASK_DIR="${PLANNING_DIR}/${TASK_SLUG}"
67
68
 
69
+ # Does this project use hit-em-with-the-docs? Self-contained copy of
70
+ # planning_uses_hewtd in scripts/lib/planning.sh: a .documentation/ tree or hewtd's
71
+ # project config. A machine-wide install does not count.
72
+ USES_HEWTD=0
73
+ if [ -d "${PROJECT_ROOT}/.documentation" ] || [ -f "${PROJECT_ROOT}/.claude/hit-em-with-the-docs.json" ]; then
74
+ USES_HEWTD=1
75
+ fi
76
+
68
77
  # Color codes
69
78
  GREEN='\033[0;32m'
70
79
  BLUE='\033[0;34m'
@@ -106,8 +115,8 @@ if [ ! -f "$TASK_PLAN_FILE" ]; then
106
115
  - [ ] Phase 3: Execute/build
107
116
  - [ ] Phase 4: Review and deliver
108
117
  - [ ] Phase 5: Cleanup -- remove junk and unused code this work created: scratch/test scripts, debug files, probe logging, one-off test functions, commented-out code, dead code from abandoned approaches (MANDATORY)
109
- - [ ] Phase 6: Validate success through comprehensive testing (MANDATORY)
110
- - [ ] Phase 7: Documentation pass -- create/update/deprecate as many docs as needed to capture what was done, where it lives, how to troubleshoot it, etc. etc.. etc.. (MANDATORY)
118
+ - [ ] Phase 6: Validate success through comprehensive testing -- we need to validate success thoroughly through comprehensive testing of our changes (MANDATORY)
119
+ - [ ] Phase 7: DOCS_PHASE_PLACEHOLDER (MANDATORY)
111
120
 
112
121
  > Phases 5, 6 and 7 are mandatory and MUST stay the last three phases of this plan.
113
122
  > Insert new work above them; never after. Renumber them if you add phases.
@@ -117,9 +126,19 @@ if [ ! -f "$TASK_PLAN_FILE" ]; then
117
126
  > imports or dependencies left unused by abandoned approaches. Only what this work
118
127
  > changed; never refactor code it did not touch. When unsure, note it -- don't delete.
119
128
  > Cleanup runs before validation so every deletion is proven safe by the tests.
120
- > - **Validate success**: prove the work with tests that fail if the change breaks.
129
+ > - **Validate success**: we need to validate success thoroughly through comprehensive
130
+ > testing of our changes. Write the tests into this plan when you write the plan --
131
+ > don't wait to be asked. List each check under Phase 6, every kind that applies:
132
+ > unit tests for new and changed logic, integration and end-to-end runs through the
133
+ > real entry points, a regression test for the problem that prompted the work, edge
134
+ > cases and failure paths, and the full existing suite. Each must fail if the change
135
+ > breaks.
121
136
  > - **Documentation pass**: create/update/deprecate every doc this change touches --
122
137
  > what it is, where it lives, how to fix it, how to operate it, why it matters.
138
+ > Capture new procedures, tools, troubleshooting steps, gotchas and KB articles too.
139
+ > Never include secrets or passwords. Write the docs work into this plan when you
140
+ > write the plan -- don't wait to be asked. List each doc under Phase 7 by file:
141
+ > every doc this work creates, changes or makes stale.
123
142
  > If hit-em-with-the-docs is installed, you MUST use it for this pass --
124
143
  > `npx hewtd integrate <file> -a` to create, `npx hewtd archive <file>` to retire,
125
144
  > `npx hewtd maintain --quick` to regenerate indexes. Never hand-edit INDEX.md or
@@ -161,6 +180,13 @@ EOF
161
180
 
162
181
  sed -i "s/TASK_NAME_PLACEHOLDER/${TASK_NAME}/g" "$TASK_PLAN_FILE"
163
182
  sed -i "s/TASK_SLUG_PLACEHOLDER/${TASK_SLUG}/g" "$TASK_PLAN_FILE"
183
+ # Both texts contain '/', hence the '|' delimiter; neither may contain '|' or '&'.
184
+ if [ "$USES_HEWTD" = "1" ]; then
185
+ DOCS_PHASE="Documentation pass -- a full hit-em-with-the-docs pass to create/update/deprecate as many docs as needed to capture all our changes: new procedures, tools, troubleshooting steps, gotchas, KB articles, etc. Never include secrets or passwords"
186
+ else
187
+ DOCS_PHASE="Documentation pass -- create/update/deprecate as many docs as needed to capture what was done, where it lives, how to troubleshoot it, etc. etc.. etc.."
188
+ fi
189
+ sed -i "s|DOCS_PHASE_PLACEHOLDER|${DOCS_PHASE}|g" "$TASK_PLAN_FILE"
164
190
  echo -e "${GREEN}+${NC} Created task_plan.md"
165
191
  else
166
192
  echo -e "${YELLOW}*${NC} task_plan.md already exists (not overwritten)"
@@ -234,6 +260,36 @@ else
234
260
  echo -e "${YELLOW}*${NC} No .gitignore found (not added)"
235
261
  fi
236
262
 
263
+ # Step 5b: Seed .claude/rules/
264
+ #
265
+ # Each templates/rules/*.md is copied once, when absent; after that the repo owns it.
266
+ # The git-workflow section is appended once (by marker) to an existing git workflow
267
+ # rule, or creates git-workflow.md. Self-contained copy of planning_seed_rules in
268
+ # scripts/lib/planning.sh. A legacy install with no templates/ beside scripts/ just
269
+ # gets no rules.
270
+ TEMPLATES_SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../templates"
271
+ RULES_DIR="${PROJECT_ROOT}/.claude/rules"
272
+ for src in "$TEMPLATES_SRC"/rules/*.md; do
273
+ [ -f "$src" ] || continue
274
+ dest="${RULES_DIR}/$(basename "$src")"
275
+ [ -e "$dest" ] && continue
276
+ if mkdir -p "$RULES_DIR" && cp "$src" "$dest"; then
277
+ echo -e "${GREEN}+${NC} Added .claude/rules/$(basename "$src")"
278
+ fi
279
+ done
280
+ GIT_SECTION="${TEMPLATES_SRC}/git-workflow-section.md"
281
+ if [ -f "$GIT_SECTION" ]; then
282
+ GIT_RULE=$(ls "$RULES_DIR" 2>/dev/null | grep -iE 'git.?(work)?flow.*\.md$' | head -1)
283
+ if [ -n "$GIT_RULE" ]; then
284
+ if ! grep -qF "$(head -1 "$GIT_SECTION")" "${RULES_DIR}/${GIT_RULE}"; then
285
+ { printf '\n'; cat "$GIT_SECTION"; } >> "${RULES_DIR}/${GIT_RULE}"
286
+ echo -e "${GREEN}+${NC} Added persistent-plan requirements to .claude/rules/${GIT_RULE}"
287
+ fi
288
+ elif mkdir -p "$RULES_DIR" && { printf '# Git Workflow\n\n'; cat "$GIT_SECTION"; } > "${RULES_DIR}/git-workflow.md"; then
289
+ echo -e "${GREEN}+${NC} Added .claude/rules/git-workflow.md"
290
+ fi
291
+ fi
292
+
237
293
  # Step 6: List other active tasks
238
294
  OTHER_TASKS=$(find "$PLANNING_DIR" -maxdepth 1 -type d -not -name ".planning" -not -path "$TASK_DIR" 2>/dev/null | wc -l)
239
295
  if [ "$OTHER_TASKS" -gt 0 ]; then
@@ -116,6 +116,8 @@ planning_insert_list_item \
116
116
  "## Tasks" \
117
117
  "- [ ] **${TASK_NAME}** (\`${TASK_SLUG}\`)"
118
118
 
119
+ planning_seed_rules "${ROOT}"
120
+
119
121
  echo ""
120
122
  planning_ok "Task '${TASK_NAME}' ready at .planning/${PARENT_PHASE}/${TASK_SLUG}/"
121
123
  echo ""
@@ -23,6 +23,10 @@
23
23
  # - planning_render_template "<src>" "<dest>" "PLACEHOLDER1=value1" "PLACEHOLDER2=value2" ...
24
24
  # Renders a template file by sed-substituting PLACEHOLDER tokens.
25
25
  # Refuses to overwrite existing dest unless PLANNING_FORCE=1 in env.
26
+ # - planning_uses_hewtd "<root>" → exit 0 when the project uses hit-em-with-the-docs
27
+ # - planning_seed_rules "<root>" → copies templates/rules/*.md into <root>/.claude/rules/
28
+ # when absent; never overwrites. Appends templates/git-workflow-section.md once to
29
+ # the repo's git workflow rule, or creates git-workflow.md
26
30
  # - planning_color_<name> → ANSI color codes (green, blue, yellow, cyan, red, reset)
27
31
  # (only set when stdout is a tty; empty otherwise)
28
32
  # - Color-coded log helpers: planning_log, planning_ok, planning_warn, planning_err
@@ -281,3 +285,60 @@ planning_ensure_archive_gitignored() {
281
285
  printf '\n# Completed plans retired by scripts/archive-plan.sh (local history)\n.planning/.archive/\n' >> "$gitignore"
282
286
  planning_ok "Added .planning/.archive/ to .gitignore (active plans stay shareable)"
283
287
  }
288
+
289
+ # planning_uses_hewtd <repo-root>
290
+ #
291
+ # True when this project uses hit-em-with-the-docs: it has a .documentation/ tree or
292
+ # hewtd's project config. A machine-wide hewtd install does not count — it would put
293
+ # hewtd steps into plans for repos that have no docs tree. init-planning.sh (sm) keeps
294
+ # a self-contained copy of this check.
295
+ planning_uses_hewtd() {
296
+ [[ -d "${1}/.documentation" || -f "${1}/.claude/hit-em-with-the-docs.json" ]]
297
+ }
298
+
299
+ # planning_seed_rules <repo-root>
300
+ #
301
+ # Copies each templates/rules/*.md into <root>/.claude/rules/ when that file is absent.
302
+ # Written once: after that the rule is the repo's, so an existing file is never
303
+ # overwritten — not even under PLANNING_FORCE, which is for plan artifacts.
304
+ #
305
+ # The git-workflow section is the exception: it is appended to the repo's existing git
306
+ # workflow rule (babel-fish writes git-workflow.md) or creates one. Its first line is a
307
+ # marker, so it is added once and a repo's edits to it stick.
308
+ #
309
+ # Reads only the plugin's own templates, never <root>/templates: that name is generic
310
+ # enough that a project could have one, and its files are not ours to load.
311
+ # init-planning.sh (sm) keeps a self-contained copy of this function.
312
+ planning_seed_rules() {
313
+ local root="$1" src dest target
314
+ local tpl_dir rules="${1}/.claude/rules"
315
+ tpl_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../templates"
316
+ for src in "$tpl_dir"/rules/*.md; do
317
+ [[ -f "$src" ]] || continue
318
+ dest="${rules}/$(basename "$src")"
319
+ [[ -e "$dest" ]] && continue
320
+ if mkdir -p "$rules" && cp "$src" "$dest"; then
321
+ planning_ok "Added .claude/rules/$(basename "$src")"
322
+ else
323
+ planning_warn "Could not write ${dest} (skipped)"
324
+ fi
325
+ done
326
+
327
+ local section="${tpl_dir}/git-workflow-section.md"
328
+ [[ -f "$section" ]] || return 0
329
+ target=$(ls "$rules" 2>/dev/null | grep -iE 'git.?(work)?flow.*\.md$' | head -1)
330
+ if [[ -n "$target" ]]; then
331
+ target="${rules}/${target}"
332
+ grep -qF "$(head -1 "$section")" "$target" && return 0
333
+ if { printf '\n'; cat "$section"; } >> "$target"; then
334
+ planning_ok "Added persistent-plan requirements to .claude/rules/$(basename "$target")"
335
+ else
336
+ planning_warn "Could not update ${target} (skipped)"
337
+ fi
338
+ elif mkdir -p "$rules" && { printf '# Git Workflow\n\n'; cat "$section"; } > "${rules}/git-workflow.md"; then
339
+ planning_ok "Added .claude/rules/git-workflow.md"
340
+ else
341
+ planning_warn "Could not write ${rules}/git-workflow.md (skipped)"
342
+ fi
343
+ return 0
344
+ }
@@ -147,7 +147,10 @@ Both tasks coexist independently. Switch between them as needed.
147
147
 
148
148
  ## task_plan.md Template
149
149
 
150
- Create this file FIRST for any complex task:
150
+ Create this file FIRST for any complex task. In a project that uses hit-em-with-the-docs
151
+ (it has `.documentation/`), the init scripts word the last phase as a full
152
+ hit-em-with-the-docs pass capturing all changes (procedures, tools, troubleshooting,
153
+ gotchas, KB articles), never secrets; lg's docs closer gets matching atoms.
151
154
 
152
155
  ```markdown
153
156
  # Task Plan: [Brief Description]
@@ -161,7 +164,7 @@ Create this file FIRST for any complex task:
161
164
  - [ ] Phase 3: Execute/build
162
165
  - [ ] Phase 4: Review and deliver
163
166
  - [ ] Phase 5: Cleanup -- remove junk and unused code this work created: scratch/test scripts, debug files, probe logging, one-off test functions, commented-out code, dead code from abandoned approaches (MANDATORY)
164
- - [ ] Phase 6: Validate success through comprehensive testing (MANDATORY)
167
+ - [ ] Phase 6: Validate success through comprehensive testing -- we need to validate success thoroughly through comprehensive testing of our changes (MANDATORY)
165
168
  - [ ] Phase 7: Documentation pass -- create/update/deprecate as many docs as needed to capture what was done, where it lives, how to troubleshoot it, etc. etc.. etc.. (MANDATORY)
166
169
 
167
170
  > Phases 5, 6 and 7 are mandatory and MUST stay the last three phases of this plan.
@@ -172,9 +175,19 @@ Create this file FIRST for any complex task:
172
175
  > imports or dependencies left unused by abandoned approaches. Only what this work
173
176
  > changed; never refactor code it did not touch. When unsure, note it -- don't delete.
174
177
  > Cleanup runs before validation so every deletion is proven safe by the tests.
175
- > - **Validate success**: prove the work with tests that fail if the change breaks.
178
+ > - **Validate success**: we need to validate success thoroughly through comprehensive
179
+ > testing of our changes. Write the tests into this plan when you write the plan --
180
+ > don't wait to be asked. List each check under Phase 6, every kind that applies:
181
+ > unit tests for new and changed logic, integration and end-to-end runs through the
182
+ > real entry points, a regression test for the problem that prompted the work, edge
183
+ > cases and failure paths, and the full existing suite. Each must fail if the change
184
+ > breaks.
176
185
  > - **Documentation pass**: create/update/deprecate every doc this change touches --
177
186
  > what it is, where it lives, how to fix it, how to operate it, why it matters.
187
+ > Capture new procedures, tools, troubleshooting steps, gotchas and KB articles too.
188
+ > Never include secrets or passwords. Write the docs work into this plan when you
189
+ > write the plan -- don't wait to be asked. List each doc under Phase 7 by file:
190
+ > every doc this work creates, changes or makes stale.
178
191
  > If hit-em-with-the-docs is installed, you MUST use it for this pass --
179
192
  > `npx hewtd integrate <file> -a` to create, `npx hewtd archive <file>` to retire,
180
193
  > `npx hewtd maintain --quick` to regenerate indexes. Never hand-edit INDEX.md or
@@ -0,0 +1,11 @@
1
+ <!-- persistent-planning:git-workflow -->
2
+ ## Persistent plans
3
+
4
+ These are hard requirements on every plan under `.planning/`:
5
+
6
+ 1. **Sync `main` first.** `git checkout main && git fetch origin main && git merge --ff-only origin/main`.
7
+ 2. **Cut a new branch** for the plan before changing anything: `git checkout -b <type>/<plan-slug>`.
8
+ 3. **Implement the plan through to completion**: every phase, including the mandatory cleanup,
9
+ validation and documentation steps, until `/plan-status` reads COMPLETE.
10
+ 4. **Commit at the end of each phase** (sm: each item under `## Phases`; lg: each task).
11
+ 5. **Finish with a single PR** for the whole plan, against `main`.
@@ -23,7 +23,7 @@ so subagent teams can pick them up concurrently.]
23
23
  _(no tasks yet — run `/start-task "Task name" --parent PHASE_SLUG_PLACEHOLDER`)_
24
24
  - [ ] **Cleanup — remove junk and unused code** (`cleanup-remove-junk-and-unused-code`) (MANDATORY — third-to-last)
25
25
  - [ ] **Validate success through comprehensive testing** (`validate-success-through-comprehensive-testing`) (MANDATORY — second-to-last)
26
- - [ ] **Documentation pass — create/update/deprecate as many docs as needed to capture what was done, where it lives, how to troubleshoot it, etc. etc.. etc..** (`documentation-pass-create-update-deprecate-docs`) (MANDATORY — last)
26
+ - [ ] **DOCS_CLOSER_PLACEHOLDER** (`documentation-pass-create-update-deprecate-docs`) (MANDATORY — last)
27
27
 
28
28
  > The three mandatory closing tasks above MUST remain the last three tasks of this phase.
29
29
  > Add new tasks above them; never after. A phase cannot be marked `done` until all three
@@ -34,9 +34,19 @@ _(no tasks yet — run `/start-task "Task name" --parent PHASE_SLUG_PLACEHOLDER`
34
34
  > or dependencies left unused by abandoned approaches. Only what this phase changed;
35
35
  > never refactor code it did not touch. It runs before validation so the tests prove
36
36
  > every deletion safe.
37
- > - **Validate success**: prove the phase's work with tests that fail if it breaks.
37
+ > - **Validate success**: we need to validate success thoroughly through comprehensive
38
+ > testing of our changes. Write the tests into this phase as you write its tasks --
39
+ > don't wait to be asked. Add each check as an atom of the validation task, every kind
40
+ > that applies: unit tests for new and changed logic, integration and end-to-end runs
41
+ > through the real entry points, a regression test for the problem that prompted the
42
+ > work, edge cases and failure paths, and the full existing suite. Each must fail if
43
+ > the change breaks.
38
44
  > - **Documentation pass**: create/update/deprecate every doc this phase touches —
39
45
  > what it is, where it lives, how to fix it, how to operate it, why it matters.
46
+ > Capture new procedures, tools, troubleshooting steps, gotchas and KB articles too.
47
+ > Never include secrets or passwords. Write the docs work into this phase as you write
48
+ > its tasks -- don't wait to be asked. Add an atom to the documentation task for each
49
+ > doc they create, change or make stale, naming the file.
40
50
  > If hit-em-with-the-docs is installed, you MUST use it for this pass --
41
51
  > `npx hewtd integrate <file> -a` to create, `npx hewtd archive <file>` to retire,
42
52
  > `npx hewtd maintain --quick` to regenerate indexes. Never hand-edit INDEX.md or
@@ -0,0 +1,35 @@
1
+ # Persistent Planning
2
+
3
+ > Auto-loaded every session. Written once by persistent-planning's init scripts and never
4
+ > overwritten: edit it to fit this repo.
5
+
6
+ Plans live in `.planning/`, on disk, so they survive context resets and can be handed to
7
+ teammates and subagents. The files are the working memory: read them, keep them current.
8
+
9
+ ## Working a plan
10
+
11
+ - **Before starting work**, run `/plan-status` and read the active plan. Re-read it before any
12
+ major decision.
13
+ - **Create plans with the commands**, never by hand: `/start-planning`, then (team mode)
14
+ `/start-task --parent <phase>` and `/start-atom --parent <task>`. They keep each parent's list
15
+ in order and the closing steps last.
16
+ - **Write the testing into the plan when you write the plan**: we need to validate success
17
+ thoroughly through comprehensive testing of our changes. Fill the validation step with the
18
+ specific checks this work needs (unit, integration, end-to-end, regression, edge cases and
19
+ failure paths, the full suite) before starting work, without being asked.
20
+ - **Write the docs work into the plan too**: under the documentation step, name each doc this
21
+ work creates, changes or makes stale, by file.
22
+ - **Update as you go**: tick each box when it is done, record decisions and errors as they
23
+ happen, and put research in `notes.md` instead of the conversation.
24
+ - The layers are **phase → task → atom**, plus **notes** for context at phase or task level.
25
+ Use those words. Do work in dependency order first; mark work `parallelizable: true` only
26
+ when nothing it depends on is unfinished.
27
+
28
+ ## Finishing a plan
29
+
30
+ - Every plan ends with three **mandatory** steps, always last, in this order: cleanup of junk
31
+ and unused code, validation by testing, a documentation pass. Add new work above them, never
32
+ after, and never skip them.
33
+ - **A plan is done when `/plan-status` says COMPLETE.** Don't mark it done any other way.
34
+ - Retire a finished plan with `/archive-plan <slug>`. Never delete a plan.
35
+ - Active plans are committed to git; only `.planning/.archive/` is ignored.