worclaude 2.7.1 → 2.9.0
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.
- package/CHANGELOG.md +71 -0
- package/README.md +72 -56
- package/package.json +1 -1
- package/src/commands/doc-lint.js +37 -0
- package/src/commands/doctor.js +145 -0
- package/src/commands/init.js +144 -44
- package/src/commands/observability.js +24 -0
- package/src/commands/regenerate-routing.js +70 -0
- package/src/commands/status.js +14 -0
- package/src/commands/upgrade.js +87 -1
- package/src/commands/worktrees.js +90 -0
- package/src/core/config.js +10 -1
- package/src/core/file-categorizer.js +16 -0
- package/src/core/merger.js +42 -20
- package/src/core/scaffolder.js +26 -0
- package/src/data/agents.js +14 -28
- package/src/data/optional-features.js +46 -0
- package/src/generators/agent-routing.js +189 -34
- package/src/index.js +37 -0
- package/src/prompts/agent-selection.js +11 -3
- package/src/utils/agent-frontmatter.js +109 -0
- package/src/utils/doc-lint.js +196 -0
- package/src/utils/observability.js +300 -0
- package/templates/agents/optional/backend/api-designer.md +7 -1
- package/templates/agents/optional/backend/auth-auditor.md +7 -1
- package/templates/agents/optional/backend/database-analyst.md +7 -1
- package/templates/agents/optional/data/data-pipeline-reviewer.md +7 -1
- package/templates/agents/optional/data/ml-experiment-tracker.md +7 -1
- package/templates/agents/optional/data/prompt-engineer.md +7 -1
- package/templates/agents/optional/devops/ci-fixer.md +7 -1
- package/templates/agents/optional/devops/dependency-manager.md +7 -1
- package/templates/agents/optional/devops/deploy-validator.md +7 -1
- package/templates/agents/optional/devops/docker-helper.md +7 -1
- package/templates/agents/optional/docs/changelog-generator.md +9 -1
- package/templates/agents/optional/docs/doc-writer.md +7 -1
- package/templates/agents/optional/frontend/style-enforcer.md +7 -1
- package/templates/agents/optional/frontend/ui-reviewer.md +7 -1
- package/templates/agents/optional/quality/bug-fixer.md +19 -1
- package/templates/agents/optional/quality/build-fixer.md +7 -1
- package/templates/agents/optional/quality/performance-auditor.md +8 -1
- package/templates/agents/optional/quality/refactorer.md +7 -1
- package/templates/agents/optional/quality/security-reviewer.md +7 -1
- package/templates/agents/universal/build-validator.md +7 -1
- package/templates/agents/universal/code-simplifier.md +8 -1
- package/templates/agents/universal/plan-reviewer.md +8 -1
- package/templates/agents/universal/test-writer.md +19 -1
- package/templates/agents/universal/upstream-watcher.md +8 -1
- package/templates/agents/universal/verify-app.md +45 -3
- package/templates/commands/build-fix.md +30 -11
- package/templates/commands/commit-push-pr.md +47 -24
- package/templates/commands/compact-safe.md +79 -7
- package/templates/commands/conflict-resolver.md +7 -3
- package/templates/commands/end.md +63 -17
- package/templates/commands/learn.md +72 -8
- package/templates/commands/observability.md +59 -0
- package/templates/commands/refactor-clean.md +44 -2
- package/templates/commands/review-changes.md +40 -11
- package/templates/commands/review-plan.md +83 -10
- package/templates/commands/start.md +61 -30
- package/templates/commands/sync.md +86 -6
- package/templates/commands/test-coverage.md +78 -12
- package/templates/commands/update-claude-md.md +96 -7
- package/templates/commands/verify.md +32 -8
- package/templates/core/claude-md.md +9 -0
- package/templates/hooks/correction-detect.cjs +1 -1
- package/templates/hooks/learn-capture.cjs +0 -2
- package/templates/hooks/obs-agent-events.cjs +55 -0
- package/templates/hooks/obs-command-invocations.cjs +53 -0
- package/templates/hooks/obs-skill-loads.cjs +54 -0
- package/templates/hooks/skill-hint.cjs +22 -2
- package/templates/scripts/start-drift.sh +29 -0
- package/templates/scripts/sync-release-scope.sh +17 -0
- package/templates/scripts/test-coverage-changed-files.sh +14 -0
- package/templates/settings/base.json +73 -0
- package/templates/skills/universal/claude-md-maintenance.md +50 -14
- package/templates/skills/universal/git-conventions.md +11 -1
- package/templates/skills/universal/memory-architecture.md +115 -0
- package/templates/skills/universal/subagent-usage.md +15 -2
- package/src/data/agent-registry.js +0 -365
- package/templates/agents/optional/quality/e2e-runner.md +0 -98
- package/templates/commands/status.md +0 -15
- package/templates/commands/techdebt.md +0 -18
- package/templates/commands/upstream-check.md +0 -85
|
@@ -1,17 +1,90 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "
|
|
2
|
+
description: "Auto-detect plans from .claude/plans/ and send to plan-reviewer with project context"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
Send
|
|
6
|
-
The plan-reviewer
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- Missing verification steps
|
|
10
|
-
- Unrealistic scope
|
|
11
|
-
- Edge cases
|
|
12
|
-
- SPEC.md alignment
|
|
5
|
+
Send an implementation plan to the `plan-reviewer` agent for staff-level
|
|
6
|
+
review. The plan-reviewer acts as a staff engineer and critically
|
|
7
|
+
reviews the plan for ambiguity, missing verification steps, unrealistic
|
|
8
|
+
scope, edge cases, and SPEC.md alignment.
|
|
13
9
|
|
|
14
|
-
|
|
10
|
+
## 1. Auto-detect the plan
|
|
11
|
+
|
|
12
|
+
Read `.claude/plans/` and list every file inside (excluding `.gitkeep`
|
|
13
|
+
and `README.md`). Behavior depends on what's present:
|
|
14
|
+
|
|
15
|
+
- **Zero plan files:** **Refuse to dispatch.** Report:
|
|
16
|
+
"No plan files found in `.claude/plans/`. Drop your plan there
|
|
17
|
+
(any filename) and re-run `/review-plan`."
|
|
18
|
+
Do not invoke the agent.
|
|
19
|
+
|
|
20
|
+
- **Exactly one plan file:** Use it directly without asking.
|
|
21
|
+
|
|
22
|
+
- **Multiple plan files:** Use **`AskUserQuestion`** (2-4 options) to
|
|
23
|
+
let the user pick which one to review. For >4 candidates, present a
|
|
24
|
+
numbered list and ask for a number reply.
|
|
25
|
+
|
|
26
|
+
Do NOT match filename patterns. The folder convention is the discovery
|
|
27
|
+
mechanism — anything in `.claude/plans/` is a candidate.
|
|
28
|
+
|
|
29
|
+
## 2. Auto-load project context
|
|
30
|
+
|
|
31
|
+
Before dispatching, read these files and pass their contents to the
|
|
32
|
+
agent so it can check SPEC alignment without a second turn:
|
|
33
|
+
|
|
34
|
+
- `CLAUDE.md` — project conventions and critical rules
|
|
35
|
+
- `docs/spec/SPEC.md` — the source of truth for what should ship
|
|
36
|
+
|
|
37
|
+
Include both in the agent's prompt under clearly-labeled sections.
|
|
38
|
+
|
|
39
|
+
## 3. Dispatch to `plan-reviewer`
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
Agent({
|
|
43
|
+
subagent_type: "plan-reviewer",
|
|
44
|
+
description: "Staff-level review of <plan-file>",
|
|
45
|
+
prompt: "Review the implementation plan below as a senior staff engineer.
|
|
46
|
+
|
|
47
|
+
PLAN (from .claude/plans/<filename>):
|
|
48
|
+
<plan content>
|
|
49
|
+
|
|
50
|
+
PROJECT CONVENTIONS (from CLAUDE.md):
|
|
51
|
+
<CLAUDE.md content>
|
|
52
|
+
|
|
53
|
+
SPECIFICATION (from docs/spec/SPEC.md):
|
|
54
|
+
<SPEC.md content>
|
|
55
|
+
|
|
56
|
+
Check for: ambiguity, missing verification steps, unrealistic scope,
|
|
57
|
+
edge cases, SPEC alignment. Report findings in priority order with
|
|
58
|
+
specific file/line references where possible."
|
|
59
|
+
})
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 4. Persist the review output
|
|
63
|
+
|
|
64
|
+
When the agent returns, **write its findings to
|
|
65
|
+
`.claude/scratch/last-plan-review.md`** with SHA frontmatter so the
|
|
66
|
+
next session can surface the review via `/start`:
|
|
67
|
+
|
|
68
|
+
```markdown
|
|
69
|
+
---
|
|
70
|
+
created: <YYYY-MM-DDTHH:MM:SSZ>
|
|
71
|
+
sha: <git rev-parse HEAD>
|
|
72
|
+
command: /review-plan
|
|
73
|
+
plan: .claude/plans/<filename>
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
# Plan Review
|
|
77
|
+
|
|
78
|
+
<agent output verbatim>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If `last-plan-review.md` already exists, **overwrite it** — only the
|
|
82
|
+
most recent review is consumed.
|
|
83
|
+
|
|
84
|
+
## 5. Report
|
|
85
|
+
|
|
86
|
+
Surface the review's priority findings to the user inline. Wait for
|
|
87
|
+
them to address feedback before proceeding to implementation.
|
|
15
88
|
|
|
16
89
|
## Trigger Phrases
|
|
17
90
|
- "review this plan"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Load session context, check for
|
|
2
|
+
description: "Load session context, check for handoffs, detect drift, surface scratch + plans"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
The SessionStart hook has already loaded CLAUDE.md, PROGRESS.md,
|
|
@@ -9,33 +9,30 @@ When invoked with arguments, use them as the task focus. Example: `/start implem
|
|
|
9
9
|
|
|
10
10
|
Arguments: $ARGUMENTS
|
|
11
11
|
|
|
12
|
-
Your job is to supplement that with drift detection
|
|
12
|
+
Your job is to supplement that with drift detection, handoff loading,
|
|
13
|
+
scratch artifact surfacing, and plan discovery.
|
|
13
14
|
|
|
14
|
-
## 1. Drift Detection
|
|
15
|
+
## 1. Drift Detection (SHA-based)
|
|
15
16
|
|
|
16
17
|
Show what changed since the last session so there are no surprises.
|
|
17
18
|
Present raw signals only — do NOT interpret or warn.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
Prefer **SHA-based drift** when the most recent session summary records
|
|
21
|
+
a HEAD SHA in its frontmatter. Otherwise fall back to date-based drift.
|
|
22
|
+
|
|
23
|
+
Run the helper script as a single command — do not unpack the script body.
|
|
24
|
+
Bundling avoids per-line permission prompts on multi-line bash with
|
|
25
|
+
`X=$(...)` assignments and `if`/`elif` blocks.
|
|
20
26
|
|
|
21
27
|
```bash
|
|
22
|
-
|
|
23
|
-
LAST_SESSION=$(ls -t .claude/sessions/*.md 2>/dev/null | head -1)
|
|
24
|
-
if [ -n "$LAST_SESSION" ]; then
|
|
25
|
-
SESSION_DATE=$(echo "$LAST_SESSION" | grep -oP '\d{4}-\d{2}-\d{2}')
|
|
26
|
-
echo "Commits since last session ($SESSION_DATE):"
|
|
27
|
-
git log --oneline --since="$SESSION_DATE" 2>/dev/null | head -15
|
|
28
|
-
else
|
|
29
|
-
echo "No previous session found. Recent commits:"
|
|
30
|
-
git log --oneline -10 2>/dev/null
|
|
31
|
-
fi
|
|
28
|
+
bash .claude/scripts/start-drift.sh
|
|
32
29
|
```
|
|
33
30
|
|
|
34
|
-
Report as:
|
|
31
|
+
The script outputs the drift list and the current branch name. Report as:
|
|
35
32
|
|
|
36
33
|
```
|
|
37
34
|
## Drift Since Last Session
|
|
38
|
-
- **X commits** since {date}
|
|
35
|
+
- **X commits** since {SHA or date}
|
|
39
36
|
- {one-liner per commit, max 15}
|
|
40
37
|
|
|
41
38
|
Current branch: {branch name}
|
|
@@ -45,36 +42,67 @@ If there are 0 commits since the last session, just say:
|
|
|
45
42
|
|
|
46
43
|
```
|
|
47
44
|
## Drift Since Last Session
|
|
48
|
-
No new commits since last session ({date}). Branch: {branch name}
|
|
45
|
+
No new commits since last session ({SHA or date}). Branch: {branch name}
|
|
49
46
|
```
|
|
50
47
|
|
|
51
48
|
Do NOT add commentary like "you should review these" or "there may be
|
|
52
49
|
conflicts." Just the facts.
|
|
53
50
|
|
|
54
|
-
## 2.
|
|
51
|
+
## 2. Read handoff and session summary as distinct artifacts
|
|
52
|
+
|
|
53
|
+
`/end` writes two files with disjoint content:
|
|
54
|
+
|
|
55
|
+
- **Handoff** at `docs/handoffs/HANDOFF-{branch}-{date}.md` — forward-
|
|
56
|
+
looking only (what's left, decisions pending, where to pick up)
|
|
57
|
+
- **Session summary** at `.claude/sessions/{YYYY-MM-DD-HHMM}-{branch}.md` —
|
|
58
|
+
backward-looking only (what got done, observability)
|
|
59
|
+
|
|
60
|
+
Read both, keeping their roles distinct. Do not merge their content into
|
|
61
|
+
a single "last session" blob:
|
|
62
|
+
|
|
63
|
+
- Look in `docs/handoffs/` for any `HANDOFF*.md` matching the current
|
|
64
|
+
branch first, then any other recent handoff. Read the most relevant.
|
|
65
|
+
- The session summary is already loaded by the SessionStart hook — re-
|
|
66
|
+
reference it for "what got done" but don't re-read it.
|
|
67
|
+
|
|
68
|
+
## 3. Surface pending scratch artifacts (SHA-matched)
|
|
69
|
+
|
|
70
|
+
Read `.claude/scratch/` and list every file inside. For each artifact
|
|
71
|
+
with a `sha:` frontmatter field, compare against `git rev-parse HEAD`:
|
|
72
|
+
|
|
73
|
+
- **SHA matches HEAD:** the artifact is fresh. Surface it prominently
|
|
74
|
+
with its purpose (e.g., "/review-changes left findings — run
|
|
75
|
+
/refactor-clean to apply them").
|
|
76
|
+
- **SHA does not match HEAD:** the artifact is stale. Mention it with a
|
|
77
|
+
"(stale, ignore)" tag. Do not delete — the user may want to inspect it.
|
|
78
|
+
- **No SHA in frontmatter:** report as "(unknown freshness)".
|
|
55
79
|
|
|
56
|
-
|
|
80
|
+
This surfacing is **generic** — list whatever is in the folder. New
|
|
81
|
+
scratch types added later don't require spec changes here.
|
|
57
82
|
|
|
58
|
-
|
|
59
|
-
- Prioritize files matching the current branch name
|
|
60
|
-
- If found, read them for context and report what was handed off
|
|
83
|
+
## 4. Discover active plans (folder, not filename pattern)
|
|
61
84
|
|
|
62
|
-
|
|
85
|
+
Read `.claude/plans/` and list every file inside (excluding `.gitkeep`
|
|
86
|
+
and `README.md`). These are the project's active plans. Surface each
|
|
87
|
+
with its first H1 heading or filename for quick scanning.
|
|
63
88
|
|
|
64
|
-
|
|
89
|
+
Do NOT match filename patterns like `PHASE-*-PROMPT.md` or
|
|
90
|
+
`IMPLEMENTATION-*.md` — the folder convention replaces pattern detection.
|
|
91
|
+
Anything in `.claude/plans/` is treated as active work guidance.
|
|
65
92
|
|
|
66
|
-
##
|
|
93
|
+
## 5. Load Agent Routing
|
|
67
94
|
|
|
68
|
-
|
|
69
|
-
project root, read it and note it.
|
|
95
|
+
Read `.claude/skills/agent-routing/SKILL.md` for agent usage guidance.
|
|
70
96
|
|
|
71
|
-
##
|
|
97
|
+
## 6. Report
|
|
72
98
|
|
|
73
99
|
Summarize:
|
|
74
100
|
|
|
75
101
|
- Drift status (from step 1)
|
|
76
|
-
-
|
|
77
|
-
-
|
|
102
|
+
- Handoff content (forward-looking, from step 2)
|
|
103
|
+
- Session summary highlights (backward-looking, already loaded)
|
|
104
|
+
- Pending scratch artifacts (from step 3)
|
|
105
|
+
- Active plans (from step 4)
|
|
78
106
|
- What's next (from PROGRESS.md loaded by hook)
|
|
79
107
|
- Any blockers or notes
|
|
80
108
|
|
|
@@ -83,3 +111,6 @@ Summarize:
|
|
|
83
111
|
- "begin working"
|
|
84
112
|
- "load context"
|
|
85
113
|
- "what changed since last time"
|
|
114
|
+
- "what's the status"
|
|
115
|
+
- "where am I"
|
|
116
|
+
- "what am I working on"
|
|
@@ -10,6 +10,10 @@ ONLY update shared-state files — do not resolve conflicts. That is
|
|
|
10
10
|
/conflict-resolver's job. If you detect unresolved conflicts, stop
|
|
11
11
|
and tell the user to run /conflict-resolver first.
|
|
12
12
|
|
|
13
|
+
## Invocation Contract
|
|
14
|
+
|
|
15
|
+
Run this command only when the human explicitly invokes it (typed `/sync` or one of the Trigger Phrases at the bottom of this file). Do not auto-launch after detecting that PRs were merged. The "ship/wait" prompt at step 9 is non-skippable. See CLAUDE.md Critical Rule 13.
|
|
16
|
+
|
|
13
17
|
## Pre-check
|
|
14
18
|
|
|
15
19
|
1. Confirm you are on the develop branch. If not, stop and warn.
|
|
@@ -19,6 +23,26 @@ and tell the user to run /conflict-resolver first.
|
|
|
19
23
|
or version tag. If nothing was merged, report "Nothing to sync"
|
|
20
24
|
and stop.
|
|
21
25
|
|
|
26
|
+
## Drift preflight
|
|
27
|
+
|
|
28
|
+
3a. Run `worclaude doctor` to surface CLAUDE.md ↔ package.json drift
|
|
29
|
+
before any shared-state file writes:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
worclaude doctor
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The `## Documentation` section reports any tech-stack claims in
|
|
36
|
+
CLAUDE.md (e.g., `857 tests, 62 files`) that no longer match the
|
|
37
|
+
current test count. If a `CLAUDE.md test-file count drift` warning
|
|
38
|
+
appears, step 10c will fix the line when it refreshes tech-stack
|
|
39
|
+
metrics — note the actual count from the warning and proceed.
|
|
40
|
+
|
|
41
|
+
If the warning is surprising (claim doesn't exist, or the delta is
|
|
42
|
+
large enough to suggest a deleted/renamed suite), pause and inspect
|
|
43
|
+
before continuing. Other doctor warnings are advisory; only the
|
|
44
|
+
drift warning is load-bearing for this sync.
|
|
45
|
+
|
|
22
46
|
## Update PROGRESS.md
|
|
23
47
|
|
|
24
48
|
4. Update docs/spec/PROGRESS.md:
|
|
@@ -37,13 +61,18 @@ and tell the user to run /conflict-resolver first.
|
|
|
37
61
|
|
|
38
62
|
## Bootstrap: ensure a version tag exists
|
|
39
63
|
|
|
40
|
-
6. Check for a version tag
|
|
64
|
+
6. Check for a version tag and capture its commit date. Run the helper as
|
|
65
|
+
a single command — do not unpack the script body.
|
|
41
66
|
|
|
42
67
|
```bash
|
|
43
|
-
|
|
68
|
+
bash .claude/scripts/sync-release-scope.sh
|
|
44
69
|
```
|
|
45
70
|
|
|
46
|
-
|
|
71
|
+
The script prints two lines: `last_tag=<tag>` and `since=<YYYY-MM-DD>`.
|
|
72
|
+
Both empty when no tag exists. Read `last_tag` from the first line.
|
|
73
|
+
|
|
74
|
+
If no tag exists (`last_tag=` is empty), prompt the user. Do NOT
|
|
75
|
+
silently auto-tag:
|
|
47
76
|
|
|
48
77
|
```
|
|
49
78
|
No version tag found. /sync needs a starting tag to compute release scope.
|
|
@@ -81,18 +110,30 @@ and tell the user to run /conflict-resolver first.
|
|
|
81
110
|
|
|
82
111
|
## Aggregate version bumps from merged PRs
|
|
83
112
|
|
|
113
|
+
**Enforcement model.** `/commit-push-pr` prompts every PR author for a
|
|
114
|
+
`Version bump:` declaration via `AskUserQuestion` and refuses to open a
|
|
115
|
+
PR without one. This step catches stragglers — manual `gh pr create`
|
|
116
|
+
calls, hot-fix branches that bypassed `/commit-push-pr`, or imports
|
|
117
|
+
from outside the workflow. Missing declarations are treated as `none`
|
|
118
|
+
**and surfaced permanently in the CHANGELOG** so under-documentation is
|
|
119
|
+
visible rather than silent. Do NOT silently upgrade missing declarations
|
|
120
|
+
to a higher level — the warning is the enforcement.
|
|
121
|
+
|
|
84
122
|
7. Collect `Version bump:` declarations from all PRs merged into develop
|
|
85
123
|
since the last version tag. Use `%as` for the date format (strict
|
|
86
124
|
YYYY-MM-DD; `%ai` breaks GitHub search due to space separator and
|
|
87
125
|
timezone offset). Pass `--limit 500` to avoid the `gh pr list` default
|
|
88
126
|
cap of 30, which would silently truncate on repos with infrequent
|
|
89
|
-
tagging
|
|
127
|
+
tagging.
|
|
128
|
+
|
|
129
|
+
The `since=<YYYY-MM-DD>` value from step 6's helper output is what you
|
|
130
|
+
pass below as `<SINCE>`. If you skipped step 6 (rare), re-run
|
|
131
|
+
`bash .claude/scripts/sync-release-scope.sh` and use its `since=` line.
|
|
90
132
|
|
|
91
133
|
```bash
|
|
92
|
-
SINCE=$(git log -1 --format=%as "$LAST_TAG")
|
|
93
134
|
gh pr list --state merged --base develop \
|
|
94
135
|
--limit 500 \
|
|
95
|
-
--search "merged
|
|
136
|
+
--search "merged:>=<SINCE>" \
|
|
96
137
|
--json number,title,body,headRefName,baseRefName
|
|
97
138
|
```
|
|
98
139
|
|
|
@@ -197,6 +238,45 @@ and tell the user to run /conflict-resolver first.
|
|
|
197
238
|
⚠-prefixed bullets under `### Changed` — not just in the transient
|
|
198
239
|
prompt. This is how under-documentation becomes permanent record.
|
|
199
240
|
|
|
241
|
+
c. Refresh tech-stack metrics in CLAUDE.md and AGENTS.md.
|
|
242
|
+
|
|
243
|
+
Both files commonly include a line like `Vitest (804 tests, 58 files)`
|
|
244
|
+
or `npm test # Run tests (804 tests, 58 files)`. These drift
|
|
245
|
+
silently as tests are added or moved.
|
|
246
|
+
|
|
247
|
+
- Run the project's test runner with a JSON-capable reporter and
|
|
248
|
+
capture the totals. Examples:
|
|
249
|
+
- Node/Vitest: `npx vitest run --reporter=json --outputFile=/tmp/_vitest.json && jq '.numTotalTests, (.testResults | length)' /tmp/_vitest.json`
|
|
250
|
+
- Node/Jest: `npx jest --json --outputFile=/tmp/_jest.json && jq '.numTotalTests, (.testResults | length)' /tmp/_jest.json`
|
|
251
|
+
- Python/pytest: `pytest --json-report --json-report-file=/tmp/_pytest.json -q && jq '.summary.total, (.tests | map(.nodeid | split("::")[0]) | unique | length)' /tmp/_pytest.json`
|
|
252
|
+
- Cargo test: count lines from `cargo test --no-run --message-format=json | jq -s '[.[] | select(.profile.test == true)] | length'`
|
|
253
|
+
|
|
254
|
+
- Search CLAUDE.md and AGENTS.md for any line matching the pattern
|
|
255
|
+
`\d+ tests?, \d+ files?`. Update each match with the captured
|
|
256
|
+
counts. If neither file contains such a line, skip silently — not
|
|
257
|
+
every project surfaces these metrics.
|
|
258
|
+
|
|
259
|
+
- Do NOT add the metrics line if it isn't already there. This step
|
|
260
|
+
only refreshes existing claims; introducing new ones is a project
|
|
261
|
+
decision, not a `/sync` decision.
|
|
262
|
+
|
|
263
|
+
## Regenerate agent-routing skill
|
|
264
|
+
|
|
265
|
+
10b. Regenerate `.claude/skills/agent-routing/SKILL.md` from the project's
|
|
266
|
+
installed agent files so it reflects whatever was added/removed/renamed
|
|
267
|
+
across the merged PRs:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
worclaude regenerate-routing
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
The regenerator reads `.claude/agents/*.md` frontmatter and replaces
|
|
274
|
+
only the content between `<!-- AUTO-GENERATED-START -->` and
|
|
275
|
+
`<!-- AUTO-GENERATED-END -->` markers — anything outside (frontmatter,
|
|
276
|
+
local notes) is preserved. If the file is missing or marker-less, a
|
|
277
|
+
fresh complete file is written. Stage the result alongside the other
|
|
278
|
+
`/sync` updates if it changed.
|
|
279
|
+
|
|
200
280
|
## Verify
|
|
201
281
|
|
|
202
282
|
11. Run /verify to confirm tests and lint pass.
|
|
@@ -7,35 +7,101 @@ Delegates to the test-writer agent for test creation.
|
|
|
7
7
|
|
|
8
8
|
## Process
|
|
9
9
|
|
|
10
|
-
1. **
|
|
10
|
+
1. **Read project coverage thresholds**
|
|
11
|
+
|
|
12
|
+
Before measuring, read the project's configured threshold so the gap
|
|
13
|
+
baseline is the project's standard, not a guess. Check in this order
|
|
14
|
+
and use the first one that exists:
|
|
15
|
+
|
|
16
|
+
- Vitest: `vitest.config.ts` / `vitest.config.js` (`test.coverage.thresholds`)
|
|
17
|
+
- Jest: `jest.config.{ts,js,cjs}` or `package.json` `jest.coverageThreshold`
|
|
18
|
+
- Pytest: `pytest.ini` / `pyproject.toml` (`[tool.coverage.report] fail_under`)
|
|
19
|
+
- Go: a `// coverage:` directive in `Makefile` or CI config
|
|
20
|
+
- Fallback: 80% line coverage if no threshold is configured
|
|
21
|
+
|
|
22
|
+
Report the threshold up front so the gap analysis has a clear bar.
|
|
23
|
+
|
|
24
|
+
2. **Measure current coverage**
|
|
25
|
+
|
|
11
26
|
Run the coverage tool for the project:
|
|
12
27
|
- Node.js: `npx vitest run --coverage` or `npx jest --coverage`
|
|
13
28
|
- Python: `pytest --cov=src --cov-report=term-missing`
|
|
14
29
|
- Go: `go test -coverprofile=coverage.out ./... && go tool cover -func=coverage.out`
|
|
15
30
|
- Read CLAUDE.md for project-specific coverage commands
|
|
16
31
|
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
3. **Identify gaps, anchored to the last release**
|
|
33
|
+
|
|
34
|
+
Focus on files with coverage **below the configured threshold** that
|
|
35
|
+
contain:
|
|
36
|
+
|
|
19
37
|
- Business logic (core domain functions)
|
|
20
38
|
- Error handling paths
|
|
21
39
|
- Integration points (DB, API, filesystem)
|
|
22
|
-
- Recently changed code
|
|
40
|
+
- **Recently changed code, anchored to the last release tag** (not an
|
|
41
|
+
arbitrary `HEAD~10`). Run the helper as a single command — do not
|
|
42
|
+
unpack the script body:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
bash .claude/scripts/test-coverage-changed-files.sh
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The helper prints one filename per line — files changed since the
|
|
49
|
+
last release tag, or the last 10 commits when no tag exists. This
|
|
50
|
+
makes "recently changed" mean "since the last release," not "since
|
|
51
|
+
some arbitrary cutoff," so coverage gaps reflect what actually ships
|
|
52
|
+
next.
|
|
53
|
+
|
|
54
|
+
4. **Prioritize by risk**
|
|
23
55
|
|
|
24
|
-
3. **Prioritize by risk**
|
|
25
56
|
Don't aim for 100% everywhere. Prioritize:
|
|
26
57
|
- HIGH: untested error handling, auth logic, data validation
|
|
27
58
|
- MEDIUM: untested business rules, state transitions
|
|
28
59
|
- LOW: untested getters, formatters, simple delegation
|
|
29
60
|
- SKIP: generated code, framework boilerplate, config files
|
|
30
61
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
62
|
+
5. **Confirm-then-delegate (do NOT write tests inline)**
|
|
63
|
+
|
|
64
|
+
Present the prioritized gap list to the user as a table:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
| # | File | Coverage | Risk | Suggested tests |
|
|
68
|
+
|---|-----------------------|----------|------|------------------------------------------|
|
|
69
|
+
| 1 | src/core/merger.js | 62% | HIGH | conflict-resolution edge cases (3 tests) |
|
|
70
|
+
| 2 | src/utils/hash.js | 45% | HIGH | empty input + non-UTF8 encoding (2 tests)|
|
|
71
|
+
| 3 | src/commands/init.js | 78% | MED | scenario-C edge case (1 test) |
|
|
72
|
+
...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Then ask the user which to close. Use **`AskUserQuestion`** when the
|
|
76
|
+
list has 2-4 candidates (its native option limit). For >4 candidates,
|
|
77
|
+
present a **numbered list** and ask the user to reply with the numbers
|
|
78
|
+
they want closed (e.g., "1, 3, 4").
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
AskUserQuestion: "Which gaps should I close?"
|
|
82
|
+
- <up to 4 file/test descriptions, one per option>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Delegate confirmed gaps to the `test-writer` agent in a worktree.**
|
|
86
|
+
Do NOT write tests inline:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
Agent({
|
|
90
|
+
subagent_type: "test-writer",
|
|
91
|
+
description: "Close coverage gaps in <files>",
|
|
92
|
+
prompt: "Coverage gaps to close:\n<confirmed list>\n
|
|
93
|
+
Project threshold: <threshold>%.
|
|
94
|
+
Follow existing test patterns. Name tests as specifications.
|
|
95
|
+
Verify each new test passes; report any that don't and why."
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The worktree isolation keeps the main session clean if test-writer's
|
|
100
|
+
exploration touches many files.
|
|
101
|
+
|
|
102
|
+
6. **Report results**
|
|
37
103
|
|
|
38
|
-
|
|
104
|
+
After the agent returns:
|
|
39
105
|
|
|
40
106
|
| File | Before | After | Tests Added | Notes |
|
|
41
107
|
|------|--------|-------|-------------|-------|
|
|
@@ -2,17 +2,106 @@
|
|
|
2
2
|
description: "Propose updates to CLAUDE.md based on session work and recurring patterns"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Propose updates to CLAUDE.md based on this session's work AND the project's
|
|
6
|
+
captured learnings. Apply changes only with explicit per-change consent.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- Any mistakes that should become rules
|
|
9
|
-
- Any patterns discovered that should be documented
|
|
10
|
-
- Any gotchas encountered
|
|
8
|
+
## Sources of proposals
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
Look at three places, in priority order:
|
|
11
|
+
|
|
12
|
+
1. **`.claude/learnings/` directory** — surface promotion candidates.
|
|
13
|
+
|
|
14
|
+
`learn-capture.cjs` writes one file per `[LEARN]` category and
|
|
15
|
+
**appends** when the same category is captured again. The directory's
|
|
16
|
+
`index.json` updates `created` to the latest capture date — treat it
|
|
17
|
+
as "last touched," not "first created." See the `memory-architecture`
|
|
18
|
+
skill for the full layer model.
|
|
19
|
+
|
|
20
|
+
Concrete promotion algorithm — a learning is a candidate when at
|
|
21
|
+
least one of these holds:
|
|
22
|
+
|
|
23
|
+
- **Recurrence:** the file at `.claude/learnings/<category>.md`
|
|
24
|
+
contains **3 or more** `**Rule:**` blocks. Count by scanning the
|
|
25
|
+
file directly (the index doesn't track count). Three independent
|
|
26
|
+
captures of the same category is the threshold for "this isn't a
|
|
27
|
+
fluke."
|
|
28
|
+
- **Recency:** the index entry's `created` date is within the last
|
|
29
|
+
**14 days**. Recent learnings are warmer signals than old ones.
|
|
30
|
+
- **Drift:** the learning's content is structurally relevant to an
|
|
31
|
+
existing `CLAUDE.md` section (e.g., a "always do X" pattern that
|
|
32
|
+
belongs in `## Critical Rules` or `## Gotchas`) but the rule is
|
|
33
|
+
missing from `CLAUDE.md`.
|
|
34
|
+
|
|
35
|
+
A candidate satisfying *only* recency is weak — surface it but rank
|
|
36
|
+
it below a recurring or drift-aligned candidate. Prefer learnings
|
|
37
|
+
that hit two or three signals at once.
|
|
38
|
+
|
|
39
|
+
**Out of scope for now:** Claude Code's auto memory at
|
|
40
|
+
`~/.claude/projects/<slug>/memory/` is NOT scanned. Auto memory is
|
|
41
|
+
personal-scoped; promotion to `CLAUDE.md` (team-scoped) requires
|
|
42
|
+
the user's explicit reasoning and is mediated through `/learn`.
|
|
43
|
+
This may be revisited once Phase 6a observability ships.
|
|
44
|
+
|
|
45
|
+
2. **This session's mistakes** — if Claude made the same mistake twice
|
|
46
|
+
in this session, it's a candidate for a Gotchas entry. Once-per-session
|
|
47
|
+
mistakes are not yet rule-worthy.
|
|
48
|
+
|
|
49
|
+
3. **This session's discoveries** — non-obvious patterns the user
|
|
50
|
+
confirmed are worth documenting (e.g., "we always do X here because Y").
|
|
51
|
+
|
|
52
|
+
## Pre-apply checks
|
|
53
|
+
|
|
54
|
+
Run these before proposing any addition:
|
|
55
|
+
|
|
56
|
+
### Size check
|
|
57
|
+
|
|
58
|
+
Read CLAUDE.md and count lines. Compare against `worclaude doctor` thresholds:
|
|
59
|
+
|
|
60
|
+
- **<= 150 lines:** safe to add. Proceed.
|
|
61
|
+
- **151–200 lines (WARN zone):** ask via `AskUserQuestion` whether to
|
|
62
|
+
proceed. Each addition pushes closer to the 200-line ERROR threshold.
|
|
63
|
+
- **>= 200 lines (ERROR zone):** **block additions** unless the user
|
|
64
|
+
explicitly accepts the bloat via `AskUserQuestion`. Strongly suggest
|
|
65
|
+
pruning before adding.
|
|
66
|
+
|
|
67
|
+
### Dedup check
|
|
68
|
+
|
|
69
|
+
For every proposed addition, scan CLAUDE.md for semantic overlap with
|
|
70
|
+
existing content. If the proposed rule restates an existing rule:
|
|
71
|
+
|
|
72
|
+
- Surface the existing rule + the proposed rule side-by-side.
|
|
73
|
+
- Offer via `AskUserQuestion`:
|
|
74
|
+
- `update in place` — replace the existing rule with the new wording
|
|
75
|
+
- `skip` — drop the proposal (existing rule covers it)
|
|
76
|
+
- `add anyway` — add the new rule alongside (rare; only if they
|
|
77
|
+
cover genuinely different angles)
|
|
78
|
+
|
|
79
|
+
Don't append duplicates silently.
|
|
80
|
+
|
|
81
|
+
## Apply mechanism
|
|
82
|
+
|
|
83
|
+
For each surviving proposed change, **prompt via `AskUserQuestion`**:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
Question: "Apply this update to CLAUDE.md?"
|
|
87
|
+
|
|
88
|
+
Proposed addition (in <section>):
|
|
89
|
+
<exact text to insert>
|
|
90
|
+
|
|
91
|
+
- yes — apply now
|
|
92
|
+
- no — drop this proposal
|
|
93
|
+
- edit — show the text, I'll refine before saving
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Refuse to write any change without an answer. **Do not batch multiple
|
|
97
|
+
changes into one prompt** — each addition gets its own consent gate so
|
|
98
|
+
the user can accept some and reject others.
|
|
99
|
+
|
|
100
|
+
When all proposals are resolved, write the resulting CLAUDE.md once
|
|
101
|
+
and report: "Applied N of M proposals. K dropped, L deduped, P deferred."
|
|
14
102
|
|
|
15
103
|
## Trigger Phrases
|
|
16
104
|
- "update CLAUDE.md"
|
|
17
105
|
- "add to rules"
|
|
18
106
|
- "update project rules"
|
|
107
|
+
- "promote learnings"
|
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Run
|
|
2
|
+
description: "Run fast read-only verification — tests + lint (and optional prettier --check)"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<!-- references package.json -->
|
|
6
|
+
|
|
7
|
+
Run the project's fast read-only verification suite.
|
|
6
8
|
|
|
7
9
|
When invoked with arguments, use them to scope what to verify. Example: `/verify just the auth module`
|
|
8
10
|
|
|
9
11
|
Arguments: $ARGUMENTS
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
## Scope (locked)
|
|
14
|
+
|
|
15
|
+
`/verify` is intentionally narrow:
|
|
16
|
+
|
|
17
|
+
1. **Run the test suite** — the project's primary test runner
|
|
18
|
+
2. **Run the linter** — fail on any lint error
|
|
19
|
+
3. **Optional: `prettier --check`** (or equivalent format check) — read-only
|
|
20
|
+
format drift detection. Skip if the project does not use a format checker.
|
|
21
|
+
|
|
22
|
+
That is the entire scope. Report results clearly. Do not proceed if any check fails.
|
|
23
|
+
|
|
24
|
+
## Read-only contract
|
|
25
|
+
|
|
26
|
+
`/verify` MUST NOT modify files. No formatter auto-fix, no test fixture
|
|
27
|
+
regeneration, no `--fix`-style flags. If a tool would write anything to disk
|
|
28
|
+
during a check, find the read-only equivalent (e.g., `prettier --check` not
|
|
29
|
+
`prettier --write`, `eslint` not `eslint --fix`).
|
|
30
|
+
|
|
31
|
+
## What is NOT in /verify
|
|
32
|
+
|
|
33
|
+
- **Build** — slow and not a "drift check." Use `/build-fix` if the build is broken.
|
|
34
|
+
- **Type checking** — covered by the `strict` hook profile's PostToolUse hook
|
|
35
|
+
for projects that want it on every edit. Not part of the standard /verify
|
|
36
|
+
contract.
|
|
37
|
+
- **Domain-specific end-to-end verification** — that is the `verify-app`
|
|
38
|
+
agent's job, invoked separately when needed.
|
|
16
39
|
|
|
17
|
-
|
|
40
|
+
This narrow scope is deliberate: /verify is the fast feedback loop.
|
|
41
|
+
Adding more checks slows it down and erodes the "run before every commit" habit.
|
|
18
42
|
|
|
19
43
|
## Trigger Phrases
|
|
20
44
|
- "verify everything"
|