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
|
@@ -5,6 +5,10 @@ description: "Commit, push, and create PR — branch-aware with session summary"
|
|
|
5
5
|
Determine which branch you're on, then follow the appropriate flow.
|
|
6
6
|
Do not add Co-Authored-By trailers or AI-generated footers to commits or PR descriptions.
|
|
7
7
|
|
|
8
|
+
## Invocation Contract
|
|
9
|
+
|
|
10
|
+
Run this command only when the human explicitly invokes it (typed `/commit-push-pr` or one of the Trigger Phrases at the bottom of this file). Do not auto-launch from a "we're done" inference. The `Version bump:` AskUserQuestion at step 6 is mandatory and never auto-answerable — refuse to proceed without an explicit human selection. See CLAUDE.md Critical Rule 13.
|
|
11
|
+
|
|
8
12
|
## Worktree Awareness
|
|
9
13
|
|
|
10
14
|
If you are in a git worktree session:
|
|
@@ -17,11 +21,17 @@ If you are in a git worktree session:
|
|
|
17
21
|
Feature branches contain ONLY the task changes. Do NOT touch shared-state
|
|
18
22
|
files (see git-conventions.md for the canonical list).
|
|
19
23
|
|
|
20
|
-
1.
|
|
21
|
-
|
|
24
|
+
1. Stage all changes: `git add -A`
|
|
25
|
+
2. Write a clear, conventional commit message and create the commit.
|
|
26
|
+
3. Capture the new HEAD SHA: `git rev-parse HEAD` — this is the value to
|
|
27
|
+
embed in the session summary's `sha:` line so the next `/start` can
|
|
28
|
+
compute drift accurately (`git log <sha>..HEAD`).
|
|
29
|
+
4. Write a session summary to `.claude/sessions/`:
|
|
30
|
+
- Filename: `YYYY-MM-DD-HHMM-{short-branch-name}.md`
|
|
22
31
|
- Content format:
|
|
23
32
|
```
|
|
24
33
|
# Session: {date}
|
|
34
|
+
sha: {full HEAD SHA captured in step 3}
|
|
25
35
|
**Branch:** {current branch}
|
|
26
36
|
**Task:** {one-line summary of what was worked on}
|
|
27
37
|
|
|
@@ -39,32 +49,45 @@ files (see git-conventions.md for the canonical list).
|
|
|
39
49
|
- **Commands used:** {all slash commands run earlier in this session, e.g. /start, /verify, /refactor-clean. Do NOT include the current /commit-push-pr or /end that is writing this summary. Write "none" if no other commands were used.}
|
|
40
50
|
- **Verification result:** {if /verify was run: passed/failed with brief summary; otherwise "not run".}
|
|
41
51
|
```
|
|
52
|
+
- The `sha:` line MUST be its own line starting with `sha:` (case-
|
|
53
|
+
sensitive, no leading whitespace, no markdown formatting around it).
|
|
54
|
+
`/start` parses it with `grep -oP '^sha:\s*\K[a-f0-9]+'`.
|
|
42
55
|
- Keep it concise — this is for machine consumption at session start,
|
|
43
|
-
not a detailed report
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
56
|
+
not a detailed report.
|
|
57
|
+
- The `.claude/sessions/` directory is gitignored; do not stage it.
|
|
58
|
+
5. Push to the current branch.
|
|
59
|
+
6. **Required: prompt for `Version bump:` declaration via AskUserQuestion.**
|
|
60
|
+
Use AskUserQuestion with these four options and one-line descriptions:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Question: "What version bump does this PR declare?"
|
|
64
|
+
|
|
65
|
+
- major — breaking change to public API, CLI, or scaffold contract
|
|
66
|
+
- minor — new feature, command, agent, or flag
|
|
67
|
+
- patch — bug fix or user-visible behavior change with no new surface
|
|
68
|
+
- none — docs, CI, tests, internal refactor (nothing consumers notice)
|
|
69
|
+
```
|
|
55
70
|
|
|
56
71
|
For revert PRs: declare the same bump level as the PR being reverted.
|
|
57
72
|
|
|
58
|
-
|
|
73
|
+
**Refuse to proceed without an answer.** No PR opens until the user
|
|
74
|
+
selects one of the four options. This is the upstream enforcement of
|
|
75
|
+
`/sync`'s release-time aggregation — every PR carries an explicit
|
|
76
|
+
declaration so `/sync` can pick max without surprises.
|
|
59
77
|
|
|
60
|
-
|
|
78
|
+
If the user's answer is genuinely ambiguous after seeing the four
|
|
79
|
+
options (rare), ask one targeted clarifying question, then re-prompt.
|
|
80
|
+
|
|
81
|
+
7. Create the PR with `gh pr create --base develop`. The PR description
|
|
82
|
+
MUST include this line on its own, verbatim:
|
|
61
83
|
|
|
62
84
|
```
|
|
63
85
|
Version bump: {major|minor|patch|none}
|
|
64
86
|
```
|
|
65
87
|
|
|
66
88
|
`/sync` parses this string exactly — other phrasings will be ignored.
|
|
67
|
-
|
|
89
|
+
|
|
90
|
+
8. Include in PR description: title, changes, testing done, reviewer notes
|
|
68
91
|
|
|
69
92
|
## On develop
|
|
70
93
|
|
|
@@ -74,13 +97,13 @@ Versioning happens in `/sync`, not here. The release PR body is pre-written
|
|
|
74
97
|
by `/sync` with the aggregated bump summary and the list of feature PRs
|
|
75
98
|
included in the release.
|
|
76
99
|
|
|
77
|
-
1.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
1. Stage all changes: `git add -A`
|
|
101
|
+
2. Write a clear, conventional commit message and create the commit.
|
|
102
|
+
3. Capture the new HEAD SHA: `git rev-parse HEAD`.
|
|
103
|
+
4. Write a session summary to `.claude/sessions/` using the same format as
|
|
104
|
+
the feature branch session summary above (including the `sha:` line).
|
|
105
|
+
5. Push to develop.
|
|
106
|
+
6. Create a PR targeting main: `gh pr create --base main`.
|
|
84
107
|
|
|
85
108
|
## On any other branch
|
|
86
109
|
|
|
@@ -2,16 +2,88 @@
|
|
|
2
2
|
description: "Compress context via /compact with safety checks"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
`/compact-safe` adds pre-flight safety checks to bare `/compact`. Compaction
|
|
6
|
+
loses fine-grained conversation state; running it on a session with
|
|
7
|
+
uncommitted work, mid-implementation TODOs, or recent destructive operations
|
|
8
|
+
risks losing context the user expected to keep. This command surfaces those
|
|
9
|
+
risks before triggering compaction.
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
## Pre-flight safety checks
|
|
12
|
+
|
|
13
|
+
Run all four checks. Report the findings as a short table. Stop and ask the
|
|
14
|
+
user for confirmation if **any** check trips.
|
|
15
|
+
|
|
16
|
+
### 1. Uncommitted changes
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
git status --porcelain
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If output is non-empty, surface a warning: "You have N uncommitted changes.
|
|
23
|
+
Compaction loses references to specific files and line numbers — consider
|
|
24
|
+
committing or stashing first."
|
|
25
|
+
|
|
26
|
+
Offer via `AskUserQuestion`:
|
|
27
|
+
- `commit` — write a WIP commit before compacting (reversible)
|
|
28
|
+
- `stash` — stash changes, compact, then `git stash pop` after
|
|
29
|
+
- `proceed` — compact anyway (you accept the risk)
|
|
30
|
+
- `cancel` — abort compaction
|
|
31
|
+
|
|
32
|
+
### 2. In-flight work signals
|
|
33
|
+
|
|
34
|
+
Scan for indicators that compaction would lose useful context:
|
|
35
|
+
|
|
36
|
+
- **Recent test failures** — check the last `npm test` / `vitest` / `pytest`
|
|
37
|
+
output if available. If there are failing tests, warn the user and offer
|
|
38
|
+
to run `/verify` first to capture the failure list before compacting.
|
|
39
|
+
- **Mid-implementation TODOs** — `grep -rn "TODO(claude)\|FIXME\|XXX" src/`
|
|
40
|
+
on files changed in the last hour (`git diff --name-only HEAD@{1.hour.ago}`
|
|
41
|
+
if available, otherwise `--name-only HEAD~1`). If matches exist, surface
|
|
42
|
+
them — they may be context Claude needs to remember.
|
|
43
|
+
|
|
44
|
+
### 3. Recent destructive operations
|
|
45
|
+
|
|
46
|
+
Check the last 20 commands in transcript or shell history for destructive
|
|
47
|
+
patterns: `rm -rf`, `git reset --hard`, `git push --force`, `DROP TABLE`,
|
|
48
|
+
etc. If any were run within the last 30 minutes, warn the user — they may
|
|
49
|
+
want to keep the conversation context until they verify the destructive
|
|
50
|
+
op landed correctly.
|
|
51
|
+
|
|
52
|
+
### 4. PostCompact hook verification
|
|
53
|
+
|
|
54
|
+
Confirm `.claude/settings.json` has a `PostCompact` hook configured. Without
|
|
55
|
+
it, compaction strips CLAUDE.md / PROGRESS.md context permanently. If the
|
|
56
|
+
hook is missing, surface a warning and stop — compacting in this state
|
|
57
|
+
silently breaks Claude's session orientation.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
node -e 'const s = require("./.claude/settings.json"); console.log(JSON.stringify(s.hooks?.PostCompact || []))'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If the output is `[]`, halt and tell the user to either fix the hook config
|
|
64
|
+
or accept the risk explicitly.
|
|
65
|
+
|
|
66
|
+
## Compaction
|
|
67
|
+
|
|
68
|
+
If all checks pass (or the user accepts each warning explicitly):
|
|
69
|
+
|
|
70
|
+
1. Run `/compact` to compress context. The PostCompact hook re-reads
|
|
71
|
+
CLAUDE.md and PROGRESS.md automatically.
|
|
72
|
+
|
|
73
|
+
2. **Post-compaction recap.** Briefly confirm:
|
|
74
|
+
- Current task
|
|
75
|
+
- Current branch
|
|
76
|
+
- What was just being worked on
|
|
77
|
+
- Any in-flight scratch artifacts the post-compact session should be aware
|
|
78
|
+
of (`.claude/scratch/last-review.md`, etc., if present and SHA-current)
|
|
79
|
+
|
|
80
|
+
If the recap surfaces something Claude no longer remembers but should,
|
|
81
|
+
that's a signal the safety checks missed something — flag it for the user
|
|
82
|
+
so they can decide whether to roll back via `git reflog` if a recovery
|
|
83
|
+
matters.
|
|
13
84
|
|
|
14
85
|
## Trigger Phrases
|
|
15
86
|
- "compact context"
|
|
16
87
|
- "free up context"
|
|
17
88
|
- "running low on context"
|
|
89
|
+
- "compact safely"
|
|
@@ -23,7 +23,12 @@ For each conflicted file:
|
|
|
23
23
|
For each conflict:
|
|
24
24
|
- Changes in DIFFERENT parts of the code → keep both
|
|
25
25
|
- Changes modify the SAME lines → combine intelligently based on intent
|
|
26
|
-
- Changes truly contradict →
|
|
26
|
+
- Changes truly contradict → use **AskUserQuestion** with three options:
|
|
27
|
+
- `keep A` — keep the incoming branch's version
|
|
28
|
+
- `keep B` — keep the current branch's version
|
|
29
|
+
- `combine` — merge both intents (you describe how)
|
|
30
|
+
|
|
31
|
+
Refuse to proceed without an answer. Never guess.
|
|
27
32
|
- NEVER silently drop changes from either side
|
|
28
33
|
|
|
29
34
|
## Step 4: Verify clean
|
|
@@ -33,8 +38,7 @@ Search ALL tracked files for remaining conflict markers
|
|
|
33
38
|
|
|
34
39
|
## Step 5: Test
|
|
35
40
|
|
|
36
|
-
Run
|
|
37
|
-
If anything fails, fix it.
|
|
41
|
+
Run `/verify`. If anything fails, fix it.
|
|
38
42
|
|
|
39
43
|
## Step 6: Commit resolution only
|
|
40
44
|
|
|
@@ -21,24 +21,70 @@ If you are working in a git worktree (not the main checkout):
|
|
|
21
21
|
|
|
22
22
|
## Mid-task handoff
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
`/end` writes two artifacts with **disjoint content**:
|
|
25
|
+
|
|
26
|
+
- **Handoff** (`docs/handoffs/HANDOFF-{branch}-{date}.md`) — **forward-looking only.**
|
|
27
|
+
What's left, decisions still pending, where to pick up. Do NOT include
|
|
28
|
+
what got done or workflow observability — those belong in the session
|
|
29
|
+
summary.
|
|
30
|
+
- **Session summary** (`.claude/sessions/{YYYY-MM-DD-HHMM}-{branch}.md`) —
|
|
31
|
+
**backward-looking only.** What got done, files modified, agents invoked,
|
|
32
|
+
commands used, verification result. Do NOT include "what's left" — that
|
|
33
|
+
belongs in the handoff.
|
|
34
|
+
|
|
35
|
+
The split is deliberate: handoffs answer "where does the next session start?",
|
|
36
|
+
session summaries answer "what happened in this session?". Mixing them makes
|
|
37
|
+
both harder to consume.
|
|
38
|
+
|
|
39
|
+
### Steps
|
|
40
|
+
|
|
41
|
+
1. **Create the handoff** at `docs/handoffs/HANDOFF-{branch-name}-{date}.md`:
|
|
42
|
+
- **What's left to do** — concrete next steps, in priority order
|
|
43
|
+
- **Decisions still pending** — items that need a human call before the
|
|
44
|
+
next session can pick them up
|
|
45
|
+
- **Where to pick up** — exact file/line/command to start with, plus any
|
|
46
|
+
scratch artifacts (`.claude/scratch/last-review.md`, etc.) that are
|
|
47
|
+
SHA-relevant
|
|
48
|
+
- **Open questions** — anything ambiguous that the next session needs to
|
|
49
|
+
resolve before continuing
|
|
50
|
+
|
|
51
|
+
2. `git add -A`
|
|
52
|
+
|
|
53
|
+
3. `git commit -m "wip: handoff for [task description]"`
|
|
40
54
|
Use exactly this message format — no trailers or Co-Authored-By lines.
|
|
41
|
-
|
|
55
|
+
|
|
56
|
+
4. Capture the new HEAD SHA: `git rev-parse HEAD`. Embed it as the
|
|
57
|
+
`sha:` line in the session summary so the next `/start` can compute
|
|
58
|
+
drift accurately (`git log <sha>..HEAD`).
|
|
59
|
+
|
|
60
|
+
5. **Write the session summary** at `.claude/sessions/YYYY-MM-DD-HHMM-{short-branch-name}.md`
|
|
61
|
+
using the same format as `/commit-push-pr` session summaries:
|
|
62
|
+
- First line: `# Session: {date}`
|
|
63
|
+
- Second line: `sha: {full HEAD SHA captured in step 4}` — own line,
|
|
64
|
+
case-sensitive, no leading whitespace, no markdown formatting around it.
|
|
65
|
+
- Mark the task as "IN PROGRESS" since `/end` means work is unfinished
|
|
66
|
+
- Fill in `## Completed` with what got done this session
|
|
67
|
+
- Fill in `## Files Modified`
|
|
68
|
+
- Fill in `## Workflow Observability`: agents invoked, slash commands
|
|
69
|
+
used so far (excluding the current `/end`), verification result
|
|
70
|
+
- Do NOT duplicate the handoff's forward-looking content here
|
|
71
|
+
- The `.claude/sessions/` directory is gitignored; do not stage it.
|
|
72
|
+
|
|
73
|
+
6. **Required: prompt for push consent via `AskUserQuestion`.**
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
Question: "Push the WIP commit to remote?"
|
|
77
|
+
|
|
78
|
+
- yes — push to origin so this branch is recoverable from another machine
|
|
79
|
+
- no — keep the WIP commit local; you'll push when you resume
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Refuse to proceed past this step without an answer. **Default to local-only**
|
|
83
|
+
if the user declines — pushing WIP commits to remote is sometimes unwanted
|
|
84
|
+
(work-in-progress visible to collaborators, broken intermediate state).
|
|
85
|
+
|
|
86
|
+
7. On `yes`: `git push`. On `no`: skip push, report "WIP commit local-only.
|
|
87
|
+
Run `git push` when you resume."
|
|
42
88
|
|
|
43
89
|
## Trigger Phrases
|
|
44
90
|
- "stop working"
|
|
@@ -9,23 +9,87 @@ Example: `/learn Always use conventional commits for this project`
|
|
|
9
9
|
|
|
10
10
|
If no arguments provided, ask the user what they want to remember.
|
|
11
11
|
|
|
12
|
-
Format
|
|
12
|
+
## Format
|
|
13
13
|
|
|
14
|
+
A learning is a `[LEARN]` block:
|
|
15
|
+
|
|
16
|
+
```
|
|
14
17
|
[LEARN] Category: One-line rule description
|
|
15
18
|
Mistake: What went wrong (optional)
|
|
16
19
|
Correction: What should happen instead (optional)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Write to `.claude/learnings/{category-slug}.md` with YAML frontmatter:
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
---
|
|
26
|
+
created: <today's date YYYY-MM-DD>
|
|
27
|
+
category: <from the [LEARN] block>
|
|
28
|
+
project: <package.json name, or directory name as fallback>
|
|
29
|
+
---
|
|
30
|
+
```
|
|
17
31
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- category: from the [LEARN] block
|
|
21
|
-
- project: current project name (from package.json name field, or directory name)
|
|
22
|
-
- times_applied: 0
|
|
32
|
+
**Do NOT add a `times_applied` field.** The auto-capture hook never
|
|
33
|
+
increments it; the field would be a lie. Removed in Phase 2 (2026-04).
|
|
23
34
|
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
After writing, **regenerate `.claude/learnings/index.json` from the
|
|
36
|
+
directory contents** — never hand-maintain it. The regeneration walks
|
|
37
|
+
`.claude/learnings/*.md`, parses each frontmatter, and writes the
|
|
38
|
+
canonical `{ "learnings": [{file, category, created}, ...] }` index.
|
|
39
|
+
This guarantees the index never drifts from the files on disk.
|
|
26
40
|
|
|
27
41
|
Confirm to the user what was saved and where.
|
|
28
42
|
|
|
43
|
+
## When to use `/learn` vs other memory layers
|
|
44
|
+
|
|
45
|
+
The system has multiple memory layers; pick the right one for the
|
|
46
|
+
trigger:
|
|
47
|
+
|
|
48
|
+
| Trigger | Lands in | Audience |
|
|
49
|
+
| ------------------------------------------ | --------------------------------------- | ------------------- |
|
|
50
|
+
| Plain conversation ("user pushes back") | Claude Code's auto-memory (autonomous) | Personal, machine-local |
|
|
51
|
+
| `/learn` or `[LEARN]` marker | `.claude/learnings/` | **Team-relevant** |
|
|
52
|
+
| `/update-claude-md` (later promotion path) | `CLAUDE.md` | Team, every session |
|
|
53
|
+
|
|
54
|
+
**`/learn` is the team signal.** Use it when the rule belongs to the
|
|
55
|
+
project, not your personal preferences. Examples:
|
|
56
|
+
|
|
57
|
+
- ✅ "We always use pnpm in this repo, not npm" → `/learn`
|
|
58
|
+
- ✅ "The conflict-resolver must not push" → `/learn`
|
|
59
|
+
- ❌ "I prefer terse responses" → leave to auto-memory; don't `/learn`
|
|
60
|
+
- ❌ "User pushes back on overengineering" → leave to auto-memory
|
|
61
|
+
|
|
62
|
+
If the rule starts personal but recurs across sessions, `/update-claude-md`
|
|
63
|
+
can later promote a stable learning to CLAUDE.md.
|
|
64
|
+
|
|
65
|
+
## Correction-triggered semi-auto path
|
|
66
|
+
|
|
67
|
+
When `correction-detect.cjs` (UserPromptSubmit hook) flags a correction in
|
|
68
|
+
the user's prompt, the hook emits a hint suggesting Claude propose a
|
|
69
|
+
learning. Claude SHOULD then:
|
|
70
|
+
|
|
71
|
+
1. Draft a one-line generalizable rule based on the correction
|
|
72
|
+
2. Prompt the user via `AskUserQuestion`:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
Question: "You corrected me: '<short paraphrase>'.
|
|
76
|
+
Proposed learning: '<concrete rule>'.
|
|
77
|
+
Capture as team learning?"
|
|
78
|
+
|
|
79
|
+
- yes — save as proposed
|
|
80
|
+
- yes, let me edit — show the text, I'll refine before saving
|
|
81
|
+
- no — drop it
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
3. On `yes` / `yes-edit` → emit a `[LEARN]` block with the agreed text.
|
|
85
|
+
The Stop hook (`learn-capture.cjs`) persists it to
|
|
86
|
+
`.claude/learnings/` automatically.
|
|
87
|
+
4. On `no` → no action. Don't re-prompt for the same correction.
|
|
88
|
+
|
|
89
|
+
This path is **targeted, not blanket**: it only fires when the
|
|
90
|
+
correction-detect regex matches. Random turns don't get a "did you
|
|
91
|
+
learn something?" prompt — that would be noise.
|
|
92
|
+
|
|
29
93
|
## Trigger Phrases
|
|
30
94
|
- "remember this"
|
|
31
95
|
- "learn this"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Per-project observability report — signal frequencies, anomalies, suggestions'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Surface the local observability report for this project. The data lives in
|
|
6
|
+
`.claude/observability/` and is captured by hooks that fire on Claude Code's
|
|
7
|
+
`InstructionsLoaded`, `UserPromptSubmit`, and `SubagentStart` / `SubagentStop`
|
|
8
|
+
events. **Zero data leaves the machine** — the folder is gitignored.
|
|
9
|
+
|
|
10
|
+
## Run
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
worclaude observability
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The CLI reads the JSONL files (skill loads, command invocations, agent
|
|
17
|
+
events), pairs agent start/stop events to compute durations, and emits a
|
|
18
|
+
Markdown report covering:
|
|
19
|
+
|
|
20
|
+
- **Top skills** by load count, with last-seen timestamp.
|
|
21
|
+
- **Top commands** by invocation count.
|
|
22
|
+
- **Agent invocations** with completed/failed counts and average duration.
|
|
23
|
+
- **Anomalies** — installed skills that never loaded, agents that fail more
|
|
24
|
+
often than they complete.
|
|
25
|
+
- **Suggestions** — skills not loaded in 30+ days (consider retiring).
|
|
26
|
+
|
|
27
|
+
Flags:
|
|
28
|
+
|
|
29
|
+
- `--json` — emit the raw report object as JSON (machine-readable).
|
|
30
|
+
- `--out <file>` — write the report to a file instead of stdout.
|
|
31
|
+
|
|
32
|
+
## Use cases
|
|
33
|
+
|
|
34
|
+
1. **Skill hygiene.** Skills that never load are noise — either rename them
|
|
35
|
+
to match the prompts users actually type, update their description for
|
|
36
|
+
`skill-hint.cjs` keyword match, or retire them.
|
|
37
|
+
2. **Agent reliability.** If an agent's failure ratio is high, look at what
|
|
38
|
+
the agent is being asked to do. The `bug-fixer` and `verify-app` agents
|
|
39
|
+
should sit near 100% completion in a healthy project.
|
|
40
|
+
3. **Command surface review.** If `/some-command` has zero invocations after
|
|
41
|
+
weeks of use, it might not be earning its slot in the surface.
|
|
42
|
+
|
|
43
|
+
## Privacy
|
|
44
|
+
|
|
45
|
+
The report is built entirely from local files. No network egress, no
|
|
46
|
+
upload, no opt-in dashboard. To disable capture entirely, set
|
|
47
|
+
`WORCLAUDE_HOOK_PROFILE=minimal` — the observability hooks short-circuit on
|
|
48
|
+
that profile (same as `learn-capture` and `correction-detect`).
|
|
49
|
+
|
|
50
|
+
To purge captured data, delete `.claude/observability/`. It will be
|
|
51
|
+
recreated empty on the next session start.
|
|
52
|
+
|
|
53
|
+
## Trigger Phrases
|
|
54
|
+
|
|
55
|
+
- "show observability"
|
|
56
|
+
- "observability report"
|
|
57
|
+
- "what's my project's observability report?"
|
|
58
|
+
- "skill usage report"
|
|
59
|
+
- "agent reliability"
|
|
@@ -32,14 +32,56 @@ the files in the current working directory.
|
|
|
32
32
|
|
|
33
33
|
## Process
|
|
34
34
|
|
|
35
|
+
### 0. Check for fresh `/review-changes` output
|
|
36
|
+
|
|
37
|
+
Before doing your own analysis, look for `.claude/scratch/last-review.md`:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
test -f .claude/scratch/last-review.md && head -10 .claude/scratch/last-review.md
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If the file exists AND its `sha:` frontmatter matches `git rev-parse HEAD`,
|
|
44
|
+
**use the review as your work plan**. Skip steps 1-3 below; jump straight
|
|
45
|
+
to step 4 with the review's findings as your candidate list.
|
|
46
|
+
|
|
47
|
+
If the SHA doesn't match, the review is stale — ignore it and proceed
|
|
48
|
+
with your own analysis.
|
|
49
|
+
|
|
50
|
+
### 1-6. Self-analysis path (only if no fresh review)
|
|
51
|
+
|
|
35
52
|
1. Identify changed files: `git diff --name-only` (unstaged) and
|
|
36
53
|
`git diff --cached --name-only` (staged). If no changes, check
|
|
37
54
|
`git diff --name-only HEAD~5` for recent commits.
|
|
38
55
|
2. Read each changed file fully — understand context before changing
|
|
39
56
|
3. Check CLAUDE.md for project-specific conventions
|
|
40
57
|
4. Make one improvement at a time, smallest meaningful change first
|
|
41
|
-
5.
|
|
42
|
-
|
|
58
|
+
5. **Scoped tests after each change.** Run only the tests related to
|
|
59
|
+
the files you changed (don't run the whole suite each time):
|
|
60
|
+
- Vitest: `npx vitest run --related <changed-files>`
|
|
61
|
+
- Jest: `npx jest --findRelatedTests <changed-files>`
|
|
62
|
+
- Other runners: scope to the relevant test directory or file pattern
|
|
63
|
+
6. If scoped tests fail, revert immediately — your change broke behavior
|
|
64
|
+
|
|
65
|
+
### 7. Full-suite safety net
|
|
66
|
+
|
|
67
|
+
After all individual changes pass their scoped tests, run the **full
|
|
68
|
+
test suite once** as a regression net:
|
|
69
|
+
|
|
70
|
+
- `npx vitest run` (or `npm test`, `pytest`, etc. — whatever the project
|
|
71
|
+
uses for the full suite)
|
|
72
|
+
|
|
73
|
+
If the full suite fails but scoped tests passed, the regression is
|
|
74
|
+
cross-cutting. Bisect the changes to find the offender, revert it.
|
|
75
|
+
|
|
76
|
+
### 8. Invalidate the review artifact
|
|
77
|
+
|
|
78
|
+
After completion, **delete `.claude/scratch/last-review.md`** (or write a
|
|
79
|
+
short marker indicating it was consumed). This prevents a future
|
|
80
|
+
`/refactor-clean` invocation from picking up an already-applied review.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
rm -f .claude/scratch/last-review.md
|
|
84
|
+
```
|
|
43
85
|
|
|
44
86
|
## Confidence Filtering
|
|
45
87
|
|
|
@@ -1,27 +1,56 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Code review — reports findings as prioritized table
|
|
2
|
+
description: "Code review — reports findings as prioritized table and writes a scratch artifact"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
Review changed code for reuse, quality, and efficiency.
|
|
6
6
|
|
|
7
|
-
CRITICAL: This is a READ-ONLY review. You MUST NOT edit
|
|
8
|
-
You MUST NOT make any commits. You MUST NOT stage changes.
|
|
9
|
-
Only analyze and
|
|
7
|
+
CRITICAL: This is a READ-ONLY review of source files. You MUST NOT edit
|
|
8
|
+
source files. You MUST NOT make any commits. You MUST NOT stage changes.
|
|
9
|
+
Only analyze, report, and write **one** scratch artifact (see step 4).
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Process
|
|
12
|
+
|
|
13
|
+
1. Read recent changes (`git diff HEAD~1` or staged changes).
|
|
12
14
|
2. Check for:
|
|
13
15
|
- Duplicated code or missed reuse opportunities
|
|
14
16
|
- Unnecessary complexity or abstraction
|
|
15
17
|
- Inconsistency with project patterns
|
|
16
18
|
- CLAUDE.md compliance issues
|
|
17
|
-
3. Report findings as a prioritized table:
|
|
19
|
+
3. Report findings as a prioritized table to the user:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
| Finding | Category | Action |
|
|
23
|
+
|---------|----------|--------|
|
|
24
|
+
| [what] | [type] | Fix / Skip — [reason] |
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
4. **Write the findings to `.claude/scratch/last-review.md`** with SHA
|
|
28
|
+
frontmatter so `/refactor-clean` can pick them up without re-analyzing.
|
|
29
|
+
|
|
30
|
+
```markdown
|
|
31
|
+
---
|
|
32
|
+
created: <YYYY-MM-DDTHH:MM:SSZ>
|
|
33
|
+
sha: <git rev-parse HEAD>
|
|
34
|
+
command: /review-changes
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
# Findings
|
|
38
|
+
|
|
39
|
+
| Finding | Category | Action |
|
|
40
|
+
|---------|----------|--------|
|
|
41
|
+
| ... | ... | ... |
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Capture the SHA via `git rev-parse HEAD` at the moment of writing. If
|
|
45
|
+
`.claude/scratch/last-review.md` already exists, **overwrite it** —
|
|
46
|
+
only the most recent review is consumed.
|
|
18
47
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
| [what] | [type] | Fix / Skip — [reason] |
|
|
48
|
+
Writing this file is the ONLY filesystem mutation `/review-changes`
|
|
49
|
+
performs. Source files remain untouched.
|
|
22
50
|
|
|
23
|
-
The user will decide which findings to act on
|
|
24
|
-
|
|
51
|
+
The user will decide which findings to act on. They can run
|
|
52
|
+
`/refactor-clean` next; it will read the scratch file and use the
|
|
53
|
+
findings as a work plan (skipping its own analysis when the SHA matches).
|
|
25
54
|
|
|
26
55
|
## Trigger Phrases
|
|
27
56
|
- "review my changes"
|