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.
Files changed (83) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +72 -56
  3. package/package.json +1 -1
  4. package/src/commands/doc-lint.js +37 -0
  5. package/src/commands/doctor.js +145 -0
  6. package/src/commands/init.js +144 -44
  7. package/src/commands/observability.js +24 -0
  8. package/src/commands/regenerate-routing.js +70 -0
  9. package/src/commands/status.js +14 -0
  10. package/src/commands/upgrade.js +87 -1
  11. package/src/commands/worktrees.js +90 -0
  12. package/src/core/config.js +10 -1
  13. package/src/core/file-categorizer.js +16 -0
  14. package/src/core/merger.js +42 -20
  15. package/src/core/scaffolder.js +26 -0
  16. package/src/data/agents.js +14 -28
  17. package/src/data/optional-features.js +46 -0
  18. package/src/generators/agent-routing.js +189 -34
  19. package/src/index.js +37 -0
  20. package/src/prompts/agent-selection.js +11 -3
  21. package/src/utils/agent-frontmatter.js +109 -0
  22. package/src/utils/doc-lint.js +196 -0
  23. package/src/utils/observability.js +300 -0
  24. package/templates/agents/optional/backend/api-designer.md +7 -1
  25. package/templates/agents/optional/backend/auth-auditor.md +7 -1
  26. package/templates/agents/optional/backend/database-analyst.md +7 -1
  27. package/templates/agents/optional/data/data-pipeline-reviewer.md +7 -1
  28. package/templates/agents/optional/data/ml-experiment-tracker.md +7 -1
  29. package/templates/agents/optional/data/prompt-engineer.md +7 -1
  30. package/templates/agents/optional/devops/ci-fixer.md +7 -1
  31. package/templates/agents/optional/devops/dependency-manager.md +7 -1
  32. package/templates/agents/optional/devops/deploy-validator.md +7 -1
  33. package/templates/agents/optional/devops/docker-helper.md +7 -1
  34. package/templates/agents/optional/docs/changelog-generator.md +9 -1
  35. package/templates/agents/optional/docs/doc-writer.md +7 -1
  36. package/templates/agents/optional/frontend/style-enforcer.md +7 -1
  37. package/templates/agents/optional/frontend/ui-reviewer.md +7 -1
  38. package/templates/agents/optional/quality/bug-fixer.md +19 -1
  39. package/templates/agents/optional/quality/build-fixer.md +7 -1
  40. package/templates/agents/optional/quality/performance-auditor.md +8 -1
  41. package/templates/agents/optional/quality/refactorer.md +7 -1
  42. package/templates/agents/optional/quality/security-reviewer.md +7 -1
  43. package/templates/agents/universal/build-validator.md +7 -1
  44. package/templates/agents/universal/code-simplifier.md +8 -1
  45. package/templates/agents/universal/plan-reviewer.md +8 -1
  46. package/templates/agents/universal/test-writer.md +19 -1
  47. package/templates/agents/universal/upstream-watcher.md +8 -1
  48. package/templates/agents/universal/verify-app.md +45 -3
  49. package/templates/commands/build-fix.md +30 -11
  50. package/templates/commands/commit-push-pr.md +47 -24
  51. package/templates/commands/compact-safe.md +79 -7
  52. package/templates/commands/conflict-resolver.md +7 -3
  53. package/templates/commands/end.md +63 -17
  54. package/templates/commands/learn.md +72 -8
  55. package/templates/commands/observability.md +59 -0
  56. package/templates/commands/refactor-clean.md +44 -2
  57. package/templates/commands/review-changes.md +40 -11
  58. package/templates/commands/review-plan.md +83 -10
  59. package/templates/commands/start.md +61 -30
  60. package/templates/commands/sync.md +86 -6
  61. package/templates/commands/test-coverage.md +78 -12
  62. package/templates/commands/update-claude-md.md +96 -7
  63. package/templates/commands/verify.md +32 -8
  64. package/templates/core/claude-md.md +9 -0
  65. package/templates/hooks/correction-detect.cjs +1 -1
  66. package/templates/hooks/learn-capture.cjs +0 -2
  67. package/templates/hooks/obs-agent-events.cjs +55 -0
  68. package/templates/hooks/obs-command-invocations.cjs +53 -0
  69. package/templates/hooks/obs-skill-loads.cjs +54 -0
  70. package/templates/hooks/skill-hint.cjs +22 -2
  71. package/templates/scripts/start-drift.sh +29 -0
  72. package/templates/scripts/sync-release-scope.sh +17 -0
  73. package/templates/scripts/test-coverage-changed-files.sh +14 -0
  74. package/templates/settings/base.json +73 -0
  75. package/templates/skills/universal/claude-md-maintenance.md +50 -14
  76. package/templates/skills/universal/git-conventions.md +11 -1
  77. package/templates/skills/universal/memory-architecture.md +115 -0
  78. package/templates/skills/universal/subagent-usage.md +15 -2
  79. package/src/data/agent-registry.js +0 -365
  80. package/templates/agents/optional/quality/e2e-runner.md +0 -98
  81. package/templates/commands/status.md +0 -15
  82. package/templates/commands/techdebt.md +0 -18
  83. package/templates/commands/upstream-check.md +0 -85
package/CHANGELOG.md CHANGED
@@ -4,6 +4,77 @@ All notable changes to worclaude are documented in this file. Format loosely fol
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [2.9.0] — 2026-04-28
8
+
9
+ Audit-driven workflow rebuild executing the canonical 7-phase plan derived from the 2026-04 master architecture audit, plus the @claude GitHub Action surface and post-phase polish. Phase 1 cleaned drift and gap-filled hooks. Phase 2 rebuilt the slash-command surface, retired three superseded commands, and split `/start`/`/end` into distinct forward-looking-handoff and backward-looking-session-summary artifacts with `sha:` frontmatter for SHA-based drift detection. Phase 3 made agent files the routing source of truth via a new frontmatter contract (`category`, `triggerType`, `whenToUse`, `whatItDoes`, `expectBack`, `situationLabel`) regenerated on every `/sync` and `worclaude upgrade`. Phase 4 introduced the memory-architecture skill and the `/update-claude-md` promotion algorithm. Phase 5 added the `worclaude doc-lint` subcommand. Phase 6a shipped end-to-end observability — capture, the `worclaude observability` aggregator, and the `/observability` slash command. Phase 7 added an `init` opt-in for the @claude GitHub Action workflow. Post-phase polish required explicit human invocation of `/commit-push-pr` or `/sync` for any git write (no more conversational "yes" authorizations) and extracted multi-line bash from three slash commands into POSIX helper scripts under `templates/scripts/` so each invocation matches a single allow rule. Test surface grew from 804/58 files to 947/69 files.
10
+
11
+ ### Added
12
+
13
+ - **`worclaude observability` subcommand + `/observability` slash command** (PR #144) — aggregates per-session captured signals into a Markdown report; `/observability` surfaces it in-session.
14
+ - **Observability capture infrastructure** (PR #143) — per-session signal capture wired into hooks; foundation that PR #144 reads from.
15
+ - **Observability upgrade-path integration + VitePress docs** (PR #145) — existing installs pick up observability infra; new VitePress page documents the flow.
16
+ - **`worclaude doc-lint` subcommand** (PR #142) — validates `<!-- references … -->` markers and surfaces tech-stack drift between code and prose; T5.9 of the canonical plan.
17
+ - **`worclaude regenerate-routing` subcommand** (PR #137, T3.1 Path B) — rebuilds `.claude/skills/agent-routing/SKILL.md` from agent-file routing-fields frontmatter (`category`, `triggerType`, `whenToUse`, `whatItDoes`, `expectBack`, `situationLabel`). Preserves user prose outside `<!-- AUTO-GENERATED-START/END -->` markers. Auto-runs during `/sync` and `worclaude upgrade`. New `src/utils/agent-frontmatter.js` parser/validator and `src/generators/agent-routing.js` builder.
18
+ - **`worclaude worktrees clean` subcommand** (PR #128) — removes stale agent worktrees left behind by Claude Code's worktree harness.
19
+ - **`/sync` refreshes test/file metrics in CLAUDE.md and AGENTS.md** (PR #128) — fixes silent drift of `\d+ tests, \d+ files` claims.
20
+ - **Default `sandbox.network.deniedDomains` in `templates/settings/base.json`** (PR #128) — opinionated baseline deny-list shipped to every fresh init.
21
+ - **`e2e-runner` agent** (PR #130) — end-to-end test orchestration; new bundled agent.
22
+ - **`Version bump:` enforcement in `/commit-push-pr`** (PR #131) — uses `AskUserQuestion` to demand a declaration on every PR; refuses to open without one.
23
+ - **Session-lifecycle redesign** (PR #132) — `/start` and `/end` write distinct artifacts: handoff (forward-looking, `docs/handoffs/HANDOFF-{branch}-{date}.md`) vs session summary (backward-looking, `.claude/sessions/{YYYY-MM-DD-HHMM}-{branch}.md`). Both carry `sha:` frontmatter for drift detection. New `/learn` and `/update-claude-md` meta/memory commands.
24
+ - **`.claude/scratch/` and `.claude/plans/` infrastructure** (PR #133) — five dependent commands (`/review-changes`, `/refactor-clean`, `/review-plan`, `/test-coverage`, `/observability`) write SHA-tagged artifacts that `/start` surfaces, distinguishing fresh from stale findings.
25
+ - **T3.6 installation rationale + T3.8 drift detect surfaces** (PR #138) — exposes detection signals to slash commands.
26
+ - **T3.9 optional features registry** (PR #139) — opt-in toggles for non-default flows surfaced through `init` and `upgrade`.
27
+ - **Memory-architecture skill + `/update-claude-md` promotion algorithm** (PR #140) — five-layer memory model (CLAUDE.md, learnings, scratch, sessions, auto-memory). `/update-claude-md` reviews learnings and proposes targeted CLAUDE.md edits with diff preview.
28
+ - **`@claude` GitHub Action surface via `init` opt-in** (PR #146) — scaffolds `.github/workflows/claude-code.yml` exposing the @claude bot; docs document the OIDC + token-exchange contract.
29
+ - **POSIX helper scripts under `templates/scripts/`** (PR #151) — `start-drift.sh`, `sync-release-scope.sh`, `test-coverage-changed-files.sh` extract multi-line bash from `/start`, `/sync`, `/test-coverage` so each invocation matches a single allow rule. New `scaffoldScripts` function wired into Scenarios A/B/C (init, merger, upgrade flows). New `'script'` file class.
30
+ - **Expanded `templates/settings/base.json` allow list** (PR #151) — `Bash(test:*)`, `Bash([:*)`, `Bash(bash:*)`, `WebFetch(domain:docs.anthropic.com|docs.claude.com|github.com|api.github.com)`, `WebSearch`, `Skill(update-config)`, `Skill(fewer-permission-prompts)` — closes the most common in-session permission-prompt fragmentation paths.
31
+ - **CLAUDE.md Critical Rule #16** (PR #150) — commit/push/PR only when the human invokes `/commit-push-pr` or `/sync` explicitly. Conversational "yes" no longer authorizes git writes; agents refuse without a slash-command trigger.
32
+
33
+ ### Changed
34
+
35
+ - ⚠ **PR #125 — 2026-04 master architecture audit + canonical 7-phase plan** — no `Version bump:` declaration (under-documented; treated as `none`). Pure docs landing into `docs/phases/`, `docs/archive/audits/2026-04/master-architecture-audit.md`, and `docs/archive/decisions/2026-04/`. Establishes the deliberation history that subsequent PRs execute against.
36
+ - **Retired 3 slash commands** (PR #130) — superseded by other workflows; net slash-command count drops from 18 to 16.
37
+ - **`/verify`, `/conflict-resolver`, `/build-fix` polished** (PR #131) — alongside the versioning enforcement work.
38
+ - **BACKLOG.md is rolling** (PR #127) — single file, items removed when scheduled; no per-release archive, no version-suffixed BACKLOG files.
39
+ - **Skill rewrite + hooks gap-fill** (PR #127) — every hook event documented in SPEC has a scaffolded handler; skills updated to current voice.
40
+
41
+ ### Fixed
42
+
43
+ - **Misleading static test count in drift display** (PR #147) — `worclaude doc-lint` no longer reports a hard-coded test count when the actual count differs.
44
+ - **Phase 1 PR A drift cleanup — text + agent metadata** (PR #126) — aligns scaffold-template prose and agent frontmatter with the routing-fields contract.
45
+
46
+ ### Tests
47
+
48
+ - **947 tests across 69 files** (was 804/58 at v2.8.0 release). Net +143 tests across the seven phases.
49
+
50
+ ### Docs
51
+
52
+ - **Comprehensive post-Phase-1-7 docs refresh** (PR #148) — counts, new commands, observability flow surfaced consistently across CLAUDE.md, README, VitePress site.
53
+ - **Phase plans archived under `docs/archive/phases/`** (PR #149) — Phase 1, 2, 3, 4, 5, 6a, 7 deliberation history preserved post-execution.
54
+ - **Phase 1 + Phase 2 retrospectives** (PRs #129, #134) — what landed vs what slipped, lessons forward.
55
+ - **Phase 3 PR A — docs contracts T3.4/T3.5/T3.7** (PR #135) — PR template, drift-allowed sentinel, consequence lines.
56
+ - **Phase 3 PR B — small wins T3.10/T3.11** (PR #136) — handoff TTL + `sha:` frontmatter dogfood across templates.
57
+ - **Phase 5 PR A — SoT markers, SPEC ToC, PR template** (PR #141) — source-of-truth markers across templates.
58
+ - **`docs/reference/permissions.md` — "Why prompts still fire" section** (PR #151) — env-var-prefix gotcha, multi-line fragmentation, pipes/redirects, the `additionalDirectories` directory-access layer, and pointer to Claude Code's built-in `/fewer-permission-prompts` skill.
59
+
60
+ ## [2.8.0] — 2026-04-24
61
+
62
+ Fixes a long-standing agent worktree correctness bug. Both `claude --worktree` and the `Agent` tool's `isolation: "worktree"` option create their isolated checkout from `origin/HEAD` — which on most worclaude-convention repos resolves to `origin/main`. When the working branch (typically `develop`) is ahead of main (the normal state mid-release-cycle), agent worktrees get a stale checkout that misses recent commits, producing "missing develop files" symptoms easy to misattribute to tooling flakiness. This release ships two complementary fixes: a new `worclaude doctor` check that detects and warns on the at-risk configuration with a local, reversible remedy (`git remote set-head origin <branch>`), and a freshness preamble on the three bundled worktree agents (`bug-fixer`, `verify-app`, `test-writer`) that resets the worktree to match the parent's current branch regardless of `origin/HEAD`. Documentation in `subagent-usage` now correctly describes the harness behavior instead of the previous "creates a worktree from your current branch" claim.
63
+
64
+ ### Added
65
+
66
+ - **`worclaude doctor` Git Integration / `origin/HEAD` divergence check** (PR #121) — warns when the current branch is ahead of `origin/HEAD`'s target, naming the branch and commit count. Suggests `git remote set-head origin <branch>` (local-only, reversible via `--auto` or `main`) as the fix. Skips silently outside a git repo or when `origin/HEAD` is unset. Shared `runGit(cwd, args)` helper added alongside for future checks to reuse the same spawn pattern.
67
+ - **Worktree freshness preamble on `bug-fixer`, `verify-app`, `test-writer` agent templates** (PR #121) — on worktree start the agent runs `git fetch origin`, identifies the parent's current branch from `git worktree list --porcelain` (filtering out auto-named `worktree-agent-*` branches), then `git reset --hard "origin/${PARENT_BRANCH}"`. Protects correctness even when the user hasn't run `set-head`. LLM-driven parsing (no `awk`/`sed` pipelines) for cross-platform portability.
68
+
69
+ ### Changed
70
+
71
+ - **`subagent-usage` skill (both `.claude/skills/subagent-usage/SKILL.md` and `templates/skills/universal/subagent-usage.md`)** (PR #121) — "How it works" item 1 corrected from "creates a worktree from your current branch" to "creates a worktree based on `origin/HEAD` (see gotcha below)". New "Base-branch gotcha" subsection cross-links to `worclaude doctor` and the `git remote set-head` remedy, and notes that the three bundled agents include a freshness preamble while other worktree agents do not.
72
+
73
+ ### Docs
74
+
75
+ - **`docs/spec/SPEC.md` doctor section** (this /sync) — adds a `### Git Integration` subsection documenting both the gitignore coverage check and the new origin/HEAD divergence check.
76
+ - **`docs/spec/PROGRESS.md`** (this /sync) — new v2.8.0 release entry; Stats refreshed (788 → 804 tests, 57 → 58 files).
77
+
7
78
  ## [2.7.1] — 2026-04-24
8
79
 
9
80
  Three `/setup` UX follow-ups from v2.7.0 confirmation testing, shipped as a single patch PR. The `?` / `help` trigger introduced in v2.7.0 turned out to collide with Claude Code's built-in keyboard-shortcut overlay (pressing `?` opens the shortcut panel before /setup's parser sees the keystroke); switched to the `help` keyword only. `worclaude init`'s `runOptionalExtras` was the only place in the init flow still using `inquirer type: 'confirm'` (rendered as `(y/N)`) — converted to `type: 'list'` arrow-key menus so every yes/no in init behaves consistently. CONFIRM_MEDIUM now invokes `AskUserQuestion` directly when the per-item option count fits the tool's `maxItems: 4` schema cap, with the consequence info ("Will be saved as") carried inside each option's `description` field; falls back to the verbatim text prompt (using `help` instead of `?`) when the count exceeds 4. CONFIRM_HIGH stays text-parse — detection lists routinely exceed 4 items. No consumer-visible schema or CLI surface additions.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src="assets/worclaude.png" alt="Worclaude The Workflow Layer for Claude Code" width="100%" />
2
+ <img src="assets/banner.png" alt="Worclaude: The Workflow Layer for Claude Code" width="100%" />
3
3
  </p>
4
4
 
5
5
  <p align="center">
@@ -23,16 +23,16 @@
23
23
  <a href="https://github.com/sefaertunc/Worclaude/issues">Issues</a>
24
24
  </p>
25
25
 
26
- # Worclaude The Workflow Layer for Claude Code
26
+ # Worclaude: The Workflow Layer for Claude Code
27
27
 
28
- Worclaude scaffolds a complete Claude Code workflow into any project in seconds. One `init` command installs 26 agents, 18 slash commands, 16 skills, 8 lifecycle hooks, a two-store memory system, and a CLAUDE.md template tuned for your tech stack. It implements the patterns in [howborisusesclaudecode.com](https://www.howborisusesclaudecode.com/) as a reusable, upgradable scaffold, so you stop rebuilding the same configuration for every new project.
28
+ Worclaude scaffolds a complete Claude Code workflow into any project in seconds. One `init` command installs 25 agents, 16 slash commands, 17 skills, an 11-event hook layer, local observability capture, a five-layer memory system, and a CLAUDE.md template tuned for your tech stack. It implements the patterns in [howborisusesclaudecode.com](https://www.howborisusesclaudecode.com/) as a reusable, upgradable scaffold, so you stop rebuilding the same configuration for every new project.
29
29
 
30
30
  <div align="center">
31
31
 
32
- | CLI Commands | Agents | Slash Commands | Skills | Hooks | Tech Stacks |
33
- | :----------: | :-----------------------: | :------------: | :-------------------: | :--------------: | :-----------: |
34
- | 8 | 6 universal + 20 optional | 18 | 16 | 8 events | 16 |
35
- | subcommands | across 6 categories | session tools | universal + templates | lifecycle events | auto-detected |
32
+ | CLI Commands | Agents | Slash Commands | Skills | Hooks | Tech Stacks |
33
+ | :----------: | :-----------------------: | :------------: | :-------------------: | :------------: | :-----------: |
34
+ | 14 | 6 universal + 19 optional | 16 | 17 | 11 events | 16 |
35
+ | subcommands | across 6 categories | session tools | universal + templates | 7 hook scripts | auto-detected |
36
36
 
37
37
  </div>
38
38
 
@@ -42,42 +42,52 @@ Worclaude scaffolds a complete Claude Code workflow into any project in seconds.
42
42
 
43
43
  `worclaude init` installs a production-ready Claude Code workflow:
44
44
 
45
- ### Agents (26 total)
45
+ ### Agents (25 total)
46
46
 
47
47
  - **6 universal:** plan-reviewer (Opus), code-simplifier (Sonnet, worktree), test-writer (Sonnet, worktree), build-validator (Haiku), verify-app (Sonnet, worktree), upstream-watcher (Sonnet)
48
- - **20 optional** across 6 categories Backend, Frontend, DevOps, Quality, Documentation, Data/AI. Worclaude recommends agents based on your project type.
48
+ - **19 optional** across 6 categories: Backend, Frontend, DevOps, Quality, Documentation, Data/AI. Worclaude recommends agents based on your project type.
49
49
 
50
- ### Slash Commands (18)
50
+ ### Slash Commands (16)
51
51
 
52
- Session lifecycle, review, verification, memory, upstream awareness, and git automation:
52
+ Session lifecycle, review, verification, memory, observability, and git automation:
53
53
 
54
- `/start` `/end` `/commit-push-pr` `/review-plan` `/techdebt` `/verify` `/compact-safe` `/status` `/update-claude-md` `/learn` `/setup` `/sync` `/conflict-resolver` `/review-changes` `/build-fix` `/refactor-clean` `/test-coverage` `/upstream-check`
54
+ `/start` `/end` `/commit-push-pr` `/review-plan` `/verify` `/compact-safe` `/update-claude-md` `/learn` `/setup` `/sync` `/conflict-resolver` `/review-changes` `/build-fix` `/refactor-clean` `/test-coverage` `/observability`
55
55
 
56
- ### Skills (16)
56
+ ### Skills (17 total)
57
57
 
58
- - **12 universal** context-management, git-conventions, planning-with-files, review-and-handoff, prompt-engineering, verification, testing, claude-md-maintenance, coding-principles, subagent-usage, security-checklist, coordinator-mode
59
- - **3 project templates** filled in automatically by `/setup` backend-conventions, frontend-design-system, project-patterns
60
- - **1 generated** agent-routing, dynamically built from your agent selections
58
+ - **13 universal**: context-management, git-conventions, planning-with-files, review-and-handoff, prompt-engineering, verification, testing, claude-md-maintenance, coding-principles, subagent-usage, security-checklist, coordinator-mode, memory-architecture
59
+ - **3 project templates** filled in automatically by `/setup`: backend-conventions, frontend-design-system, project-patterns
60
+ - **1 generated**: agent-routing, dynamically built from your agent selections
61
61
 
62
62
  Skills use Claude Code's directory format (`skill-name/SKILL.md`) and support **conditional activation** via path globs, so Claude only carries knowledge relevant to the current file.
63
63
 
64
- ### Hooks (8 lifecycle events)
64
+ ### Hooks (11 events, 7 hook scripts)
65
65
 
66
- Worclaude scaffolds hooks across the full Claude Code lifecycle:
66
+ Worclaude scaffolds 14 hook entries across 11 Claude Code events:
67
67
 
68
- - **SessionStart** auto-loads CLAUDE.md, PROGRESS.md, last session summary, and recent learnings
69
- - **PostToolUse** auto-formats code after every edit, using the right formatter for your stack
70
- - **PostCompact** re-reads key files after context compaction so Claude stays oriented
71
- - **PreCompact** emergency git snapshot before auto-compaction
72
- - **UserPromptSubmit** detects correction signals and suggests skills based on prompt content
73
- - **Stop** extracts `[LEARN]` blocks from the transcript and persists them to disk
74
- - **SessionEnd / Notification** quiet-by-default session-end and desktop alerts
68
+ - **SessionStart**: auto-loads CLAUDE.md, PROGRESS.md, last session summary, and recent learnings
69
+ - **PostToolUse**: auto-formats code after every edit (formatter chosen by stack); strict profile adds a TypeScript check
70
+ - **PostCompact**: re-reads key files after context compaction so Claude stays oriented
71
+ - **PreCompact**: emergency git snapshot before auto-compaction (`pre-compact-save.cjs`)
72
+ - **UserPromptSubmit**: three handlers run in sequence (correction-detection, skill-hint matching, and command-invocation observability capture)
73
+ - **Stop**: extracts `[LEARN]` blocks from the transcript and persists them (`learn-capture.cjs`)
74
+ - **InstructionsLoaded**: captures skill loads to `.claude/observability/skill-loads.jsonl` (`obs-skill-loads.cjs`)
75
+ - **SubagentStart / SubagentStop**: captures agent invocations to `.claude/observability/agent-events.jsonl` (`obs-agent-events.cjs`)
76
+ - **SessionEnd / Notification**: quiet-by-default session-end and desktop alerts
75
77
 
76
- Three profiles via `WORCLAUDE_HOOK_PROFILE`: `minimal` (context hooks only), `standard` (all hooks, default), `strict` (standard + TypeScript checking on every edit).
78
+ Three profiles via `WORCLAUDE_HOOK_PROFILE`: `minimal` (context hooks only; disables observability and notifications), `standard` (all hooks, default), `strict` (standard + TypeScript checking on every edit).
79
+
80
+ ### Observability
81
+
82
+ A privacy-first per-project signal layer captures skill loads, command invocations, and agent timings to `.claude/observability/*.jsonl` (gitignored). The `worclaude observability` CLI and `/observability` slash command aggregate the signals into a Markdown report: top skills, top commands, agent failure rates, and anomalies. Zero data leaves the machine; opt out via `WORCLAUDE_HOOK_PROFILE=minimal` or by deleting the folder.
83
+
84
+ ### GitHub Action Integration
85
+
86
+ When `worclaude init` finishes it offers to surface Claude Code's `/install-github-action` flow. If installed, `@claude` mentions in PR comments will automatically propose CLAUDE.md updates, slotting cleanly into the `/sync`-driven release flow. Worclaude itself never shells out to the install command; it just points you at it.
77
87
 
78
88
  ### Learnings System
79
89
 
80
- A personal, gitignored store at `.claude/learnings/` captures corrections and rules Claude picks up mid-session and replays them at the start of future sessions. The `correction-detect.cjs` and `learn-capture.cjs` hooks do this automatically; the `/learn` slash command is the explicit capture path. Unlike CLAUDE.md (shared rules, in git), learnings are yours useful for personal conventions that should not leak into the repo. Promote a learning to CLAUDE.md when it matures into something every contributor should follow.
90
+ A personal, gitignored store at `.claude/learnings/` captures corrections and rules Claude picks up mid-session and replays them at the start of future sessions. The `correction-detect.cjs` and `learn-capture.cjs` hooks do this automatically; the `/learn` slash command is the explicit capture path. Unlike CLAUDE.md (shared rules, in git), learnings are yours; useful for personal conventions that should not leak into the repo. Promote a learning to CLAUDE.md when it matures into something every contributor should follow.
81
91
 
82
92
  ### Cross-Tool Compatibility
83
93
 
@@ -119,18 +129,24 @@ claude --worktree --tmux
119
129
 
120
130
  ## Commands
121
131
 
122
- | Command | Description |
123
- | ------------------- | ----------------------------------------------------------- |
124
- | `worclaude init` | Scaffold workflow into new or existing project |
125
- | `worclaude upgrade` | Update universal components and repair on-disk drift |
126
- | `worclaude status` | Show current workflow state, version, and npm update status |
127
- | `worclaude backup` | Create a timestamped backup of workflow files |
128
- | `worclaude restore` | Restore from a previous backup |
129
- | `worclaude diff` | Compare current setup vs latest template |
130
- | `worclaude delete` | Remove worclaude workflow from project |
131
- | `worclaude doctor` | Validate workflow installation health |
132
-
133
- The `init` command detects existing setups and merges intelligently — no data is overwritten without your confirmation. Use `upgrade` to pull in new features, restore missing files, and preserve your customizations. `upgrade` accepts `--dry-run`, `--yes`, and `--repair-only` for scripted flows.
132
+ | Command | Description |
133
+ | ------------------------------ | ------------------------------------------------------------------------ |
134
+ | `worclaude init` | Scaffold workflow into new or existing project |
135
+ | `worclaude upgrade` | Update universal components and repair on-disk drift |
136
+ | `worclaude status` | Show current workflow state, version, and npm update status |
137
+ | `worclaude backup` | Create a timestamped backup of workflow files |
138
+ | `worclaude restore` | Restore from a previous backup |
139
+ | `worclaude diff` | Compare current setup vs latest template |
140
+ | `worclaude delete` | Remove worclaude workflow from project |
141
+ | `worclaude doctor` | Validate workflow installation health |
142
+ | `worclaude doc-lint` | Validate `<!-- references … -->` markers; surface tech-stack drift |
143
+ | `worclaude observability` | Aggregate per-project signals into a Markdown report (`--json`, `--out`) |
144
+ | `worclaude regenerate-routing` | Rebuild `agent-routing/SKILL.md` from `templates/agents/` |
145
+ | `worclaude scan` | Detect project type/stack via the project-scanner detectors |
146
+ | `worclaude setup-state` | Inspect / save / reset / resume `/setup` interview persistence |
147
+ | `worclaude worktrees clean` | Remove stale agent worktrees (locked or orphaned) |
148
+
149
+ The `init` command detects existing setups and merges intelligently; no data is overwritten without your confirmation. Use `upgrade` to pull in new features, restore missing files, and preserve your customizations. `upgrade` accepts `--dry-run`, `--yes`, and `--repair-only` for scripted flows. `doctor` accepts `--json` for CI dashboards. `doc-lint` accepts `--strict` to exit non-zero on drift (CI-friendly).
134
150
 
135
151
  See the [full command reference](https://sefaertunc.github.io/Worclaude/reference/commands) for detailed usage and options.
136
152
 
@@ -139,11 +155,11 @@ See the [full command reference](https://sefaertunc.github.io/Worclaude/referenc
139
155
  ## Why Worclaude
140
156
 
141
157
  - **Split architecture.** CLAUDE.md stays under 200 lines for speed; detail lives in skills loaded on demand. Personal rules live in `.claude/learnings/` (gitignored); shared rules live in CLAUDE.md.
142
- - **Learning loop.** Correct Claude once, it captures the rule, the next session picks it up at start no re-stating.
158
+ - **Learning loop.** Correct Claude once, it captures the rule, the next session picks it up at start; no re-stating.
143
159
  - **Cross-tool ready.** `AGENTS.md` generated from the same source as CLAUDE.md, so your rules work in Cursor / Codex / Copilot too.
144
160
  - **Hook profiles.** Dial strictness up or down via one environment variable. `minimal` for CI, `standard` for daily work, `strict` for type-heavy projects.
145
- - **Smart merge.** Detects existing Claude Code setups and merges additively existing files never overwritten without confirmation. Three-tier strategy: additive for missing content, safe-alongside for conflicts, interactive for CLAUDE.md.
146
- - **Self-healing doctor.** Catches drift, stale hashes, deprecated models, broken learnings before they bite.
161
+ - **Smart merge.** Detects existing Claude Code setups and merges additively; existing files never overwritten without confirmation. Three-tier strategy: additive for missing content, safe-alongside for conflicts, interactive for CLAUDE.md.
162
+ - **Self-healing doctor.** Catches drift, stale hashes, deprecated models, broken learnings; before they bite.
147
163
  - **Batched releases.** Every PR declares `Version bump: {major|minor|patch|none}` in its body; `/sync` aggregates declarations across merged PRs and only cuts a release when at least one rises above `none`. Internal-only work (docs, CI, tests) accumulates on `develop` without triggering noisy publishes.
148
164
 
149
165
  ---
@@ -152,25 +168,25 @@ See the [full command reference](https://sefaertunc.github.io/Worclaude/referenc
152
168
 
153
169
  Worclaude draws from patterns and insights across the Claude Code ecosystem:
154
170
 
155
- - [Boris Cherny's Claude Code tips](https://howborisusesclaudecode.com/) The foundational workflow patterns: multi-terminal pipelines, plan-then-execute, CLAUDE.md as shared knowledge, verification-first development
156
- - [everything-claude-code](https://github.com/affaan-m/everything-claude-code) by Affaan Mir (Anthropic hackathon winner) Session persistence, hook profiles, confidence filtering, security scanning patterns
157
- - [Andrej Karpathy's coding principles](https://github.com/multica-ai/andrej-karpathy-skills) Think before coding, simplicity first, surgical changes ([original post](https://x.com/karpathy/status/2015883857489522876))
158
- - [pro-workflow](https://github.com/peterHoburg/pro-workflow) Correction detection, learning capture hooks, loop prevention patterns
159
- - [Anthropic Engineering Blog](https://www.anthropic.com/engineering) Agent design, context engineering, harness patterns
160
- - [awesome-claude-code](https://github.com/hesreallyhim/awesome-claude-code) by hesreallyhim Community resource discovery and ecosystem awareness
161
- - [awesome-claude-code-toolkit](https://github.com/rohitg00/awesome-claude-code-toolkit) by rohitg00 Toolkit patterns and companion app references
162
- - [claude-skills-cli](https://github.com/anthropics/skills) Skill activation patterns and conditional loading insights
163
- - [SuperClaude](https://github.com/andyholst/SuperClaude) Persona and mode system analysis (informed what NOT to build)
164
- - [ccusage](https://github.com/yashikota/ccusage) / [claude-devtools](https://github.com/nicobailey/claude-devtools) Observability patterns (informed what NOT to build)
165
- - [claude-flow](https://github.com/Ruflo/claude-flow) by Ruflo Runtime orchestration patterns (informed the scaffolding-only philosophy)
166
- - [Vercel SkillKit](https://github.com/vercel/skillkit) Skill packaging and marketplace patterns
167
- - [claude-code-templates](https://github.com/danielsalas/claude-code-templates) by Daniel Avila Template gallery and component catalog reference
171
+ - [Boris Cherny's Claude Code tips](https://howborisusesclaudecode.com/): The foundational workflow patterns: multi-terminal pipelines, plan-then-execute, CLAUDE.md as shared knowledge, verification-first development
172
+ - [everything-claude-code](https://github.com/affaan-m/everything-claude-code) by Affaan Mir (Anthropic hackathon winner): Session persistence, hook profiles, confidence filtering, security scanning patterns
173
+ - [Andrej Karpathy's coding principles](https://github.com/multica-ai/andrej-karpathy-skills): Think before coding, simplicity first, surgical changes ([original post](https://x.com/karpathy/status/2015883857489522876))
174
+ - [pro-workflow](https://github.com/peterHoburg/pro-workflow): Correction detection, learning capture hooks, loop prevention patterns
175
+ - [Anthropic Engineering Blog](https://www.anthropic.com/engineering): Agent design, context engineering, harness patterns
176
+ - [awesome-claude-code](https://github.com/hesreallyhim/awesome-claude-code) by hesreallyhim: Community resource discovery and ecosystem awareness
177
+ - [awesome-claude-code-toolkit](https://github.com/rohitg00/awesome-claude-code-toolkit) by rohitg00: Toolkit patterns and companion app references
178
+ - [claude-skills-cli](https://github.com/anthropics/skills): Skill activation patterns and conditional loading insights
179
+ - [SuperClaude](https://github.com/andyholst/SuperClaude): Persona and mode system analysis (informed what NOT to build)
180
+ - [ccusage](https://github.com/yashikota/ccusage) / [claude-devtools](https://github.com/nicobailey/claude-devtools): Observability patterns (informed what NOT to build)
181
+ - [claude-flow](https://github.com/Ruflo/claude-flow) by Ruflo: Runtime orchestration patterns (informed the scaffolding-only philosophy)
182
+ - [Vercel SkillKit](https://github.com/vercel/skillkit): Skill packaging and marketplace patterns
183
+ - [claude-code-templates](https://github.com/danielsalas/claude-code-templates) by Daniel Avila: Template gallery and component catalog reference
168
184
 
169
185
  ---
170
186
 
171
187
  ## Links
172
188
 
173
- - [Full Documentation](https://sefaertunc.github.io/Worclaude/) VitePress site with guides and reference
189
+ - [Full Documentation](https://sefaertunc.github.io/Worclaude/): VitePress site with guides and reference
174
190
  - [npm Package](https://www.npmjs.com/package/worclaude)
175
191
  - [GitHub Issues](https://github.com/sefaertunc/Worclaude/issues)
176
192
  - [Contributing](CONTRIBUTING.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worclaude",
3
- "version": "2.7.1",
3
+ "version": "2.9.0",
4
4
  "description": "The Workflow Layer for Claude Code — scaffold agents, commands, skills, hooks, and memory into any project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,37 @@
1
+ import { lintRepo } from '../utils/doc-lint.js';
2
+ import * as display from '../utils/display.js';
3
+
4
+ export async function docLintCommand(options = {}) {
5
+ const projectRoot = process.cwd();
6
+ const result = await lintRepo(projectRoot);
7
+
8
+ if (!result.hasDrift) {
9
+ display.success(`doc-lint clean — ${result.markerCount} marker(s) checked, no drift.`);
10
+ return;
11
+ }
12
+
13
+ display.newline();
14
+ display.barLine(`Drift in ${result.findings.length} location(s):`);
15
+ for (const f of result.findings) {
16
+ if (f.kind === 'test-count-drift') {
17
+ display.barLine(
18
+ ` ${f.file}:${f.claimLine} — claims ${f.claimed.files} test files (actual ${f.actual.files})`
19
+ );
20
+ } else if (f.kind === 'missing-npm-script') {
21
+ display.barLine(
22
+ ` ${f.file}:${f.markerLine} — references \`npm run ${f.scriptName}\` but no such script in package.json`
23
+ );
24
+ } else {
25
+ display.barLine(` ${f.file}:${f.markerLine} — ${f.kind}`);
26
+ }
27
+ }
28
+
29
+ display.newline();
30
+ display.dim(
31
+ 'Fix by running /sync (refreshes both test count and file count in step 10c via the test runner) or by editing the cited section.'
32
+ );
33
+
34
+ if (options.strict) {
35
+ process.exitCode = 1;
36
+ }
37
+ }
@@ -11,6 +11,7 @@ import {
11
11
  TEMPLATE_SKILLS,
12
12
  } from '../data/agents.js';
13
13
  import { hasClaudeMdMemoryGuidance, readClaudeMd } from '../core/drift-checks.js';
14
+ import { lintRepo } from '../utils/doc-lint.js';
14
15
  import { resolveKeyPath, isWorkflowRefFile } from '../core/file-categorizer.js';
15
16
  import * as display from '../utils/display.js';
16
17
 
@@ -98,6 +99,42 @@ function printResult(r) {
98
99
  }
99
100
  }
100
101
 
102
+ function checkInstallationRationale(meta) {
103
+ // Old installs scaffolded before T3.6 lack the field — do not flag.
104
+ if (!meta || !meta.installation) return null;
105
+ const { rationale } = meta.installation;
106
+ if (typeof rationale !== 'string' || rationale.trim() === '') {
107
+ return result(WARN, 'Installation rationale', 'Field present but rationale is empty');
108
+ }
109
+ return result(PASS, `Installation rationale: ${rationale}`, null);
110
+ }
111
+
112
+ async function checkDocLint(projectRoot) {
113
+ const lint = await lintRepo(projectRoot);
114
+ if (lint.markerCount === 0) return null;
115
+ if (!lint.hasDrift) {
116
+ return result(PASS, `doc-lint: ${lint.markerCount} marker(s) match their source`, null);
117
+ }
118
+ const summary = lint.findings
119
+ .slice(0, 3)
120
+ .map((f) => {
121
+ if (f.kind === 'test-count-drift') {
122
+ return `${f.file}:${f.claimLine} claims ${f.claimed.files} files (actual ${f.actual.files})`;
123
+ }
124
+ if (f.kind === 'missing-npm-script') {
125
+ return `${f.file}:${f.markerLine} references missing script \`npm run ${f.scriptName}\``;
126
+ }
127
+ return `${f.file}:${f.markerLine} ${f.kind}`;
128
+ })
129
+ .join('; ');
130
+ const more = lint.findings.length > 3 ? ` (+${lint.findings.length - 3} more)` : '';
131
+ return result(
132
+ WARN,
133
+ `doc-lint: ${lint.findings.length} drift finding(s)`,
134
+ `${summary}${more}. Run /sync to refresh tech-stack metrics, or fix the cited section.`
135
+ );
136
+ }
137
+
101
138
  async function checkWorkflowMeta(projectRoot) {
102
139
  if (!(await workflowMetaExists(projectRoot))) {
103
140
  return result(FAIL, 'workflow-meta.json', 'Missing — run `worclaude init` to create');
@@ -838,6 +875,108 @@ async function checkGitignore(projectRoot) {
838
875
  return results;
839
876
  }
840
877
 
878
+ function runGit(projectRoot, args) {
879
+ try {
880
+ const r = spawnSync('git', args, { cwd: projectRoot, encoding: 'utf8' });
881
+ if (r.error) return { status: -1, stdout: '', stderr: String(r.error) };
882
+ return {
883
+ status: r.status,
884
+ stdout: (r.stdout || '').trim(),
885
+ stderr: (r.stderr || '').trim(),
886
+ };
887
+ } catch (err) {
888
+ return { status: -1, stdout: '', stderr: String(err) };
889
+ }
890
+ }
891
+
892
+ async function checkOriginHead(projectRoot) {
893
+ const skipped = result(PASS, 'origin/HEAD check skipped', null);
894
+
895
+ const headRef = runGit(projectRoot, ['symbolic-ref', 'refs/remotes/origin/HEAD']);
896
+ if (headRef.status === 128) return skipped;
897
+ if (headRef.status !== 0) {
898
+ return result(
899
+ WARN,
900
+ 'origin/HEAD not set',
901
+ 'Run `git remote set-head origin --auto` (or `git remote set-head origin <branch>`) so worktree agents have a defined base'
902
+ );
903
+ }
904
+
905
+ const defaultBranch = headRef.stdout.replace(/^refs\/remotes\/origin\//, '');
906
+ if (!defaultBranch) {
907
+ return result(WARN, 'origin/HEAD malformed', `Unexpected ref: ${headRef.stdout}`);
908
+ }
909
+
910
+ const currentRef = runGit(projectRoot, ['branch', '--show-current']);
911
+ if (currentRef.status !== 0) return skipped;
912
+
913
+ const currentBranch = currentRef.stdout;
914
+ if (!currentBranch) {
915
+ return result(PASS, `origin/HEAD → ${defaultBranch} (detached HEAD, skipped)`, null);
916
+ }
917
+ if (currentBranch === defaultBranch) {
918
+ return result(PASS, `origin/HEAD → ${defaultBranch} (matches current branch)`, null);
919
+ }
920
+
921
+ const ahead = runGit(projectRoot, [
922
+ 'rev-list',
923
+ '--count',
924
+ `origin/${defaultBranch}..${currentBranch}`,
925
+ ]);
926
+ if (ahead.status !== 0) {
927
+ return result(PASS, `origin/HEAD → ${defaultBranch}`, null);
928
+ }
929
+ const aheadCount = Number.parseInt(ahead.stdout, 10) || 0;
930
+ if (aheadCount === 0) {
931
+ return result(
932
+ PASS,
933
+ `origin/HEAD → ${defaultBranch}, current '${currentBranch}' not ahead`,
934
+ null
935
+ );
936
+ }
937
+
938
+ return result(
939
+ WARN,
940
+ `Current branch '${currentBranch}' is ${aheadCount} commit(s) ahead of origin/${defaultBranch}`,
941
+ `Worktree agents (claude --worktree, Agent isolation:worktree) base off origin/${defaultBranch} and will miss those commits. Fix: \`git remote set-head origin ${currentBranch}\` (local-only, reversible with \`--auto\` or \`main\`)`
942
+ );
943
+ }
944
+
945
+ const STALE_WORKTREE_THRESHOLD = 3;
946
+
947
+ async function checkStaleWorktrees(projectRoot) {
948
+ const worktreesDir = path.join(projectRoot, '.claude', 'worktrees');
949
+ if (!(await fs.pathExists(worktreesDir))) {
950
+ return result(PASS, '.claude/worktrees/ (none)', null);
951
+ }
952
+
953
+ let entries;
954
+ try {
955
+ entries = await fs.readdir(worktreesDir);
956
+ } catch {
957
+ return result(PASS, '.claude/worktrees/ (unreadable, skipped)', null);
958
+ }
959
+
960
+ const dirs = [];
961
+ for (const name of entries) {
962
+ if (name.startsWith('.')) continue;
963
+ const stat = await fs.stat(path.join(worktreesDir, name)).catch(() => null);
964
+ if (stat && stat.isDirectory()) dirs.push(name);
965
+ }
966
+
967
+ if (dirs.length === 0) {
968
+ return result(PASS, '.claude/worktrees/ (empty)', null);
969
+ }
970
+ if (dirs.length <= STALE_WORKTREE_THRESHOLD) {
971
+ return result(PASS, `.claude/worktrees/ (${dirs.length} present)`, null);
972
+ }
973
+ return result(
974
+ WARN,
975
+ `.claude/worktrees/ has ${dirs.length} entries (threshold ${STALE_WORKTREE_THRESHOLD})`,
976
+ 'Locked agent worktrees survive `git worktree prune`. Run `worclaude worktrees clean` to force-remove them.'
977
+ );
978
+ }
979
+
841
980
  async function checkPendingReviewFiles(projectRoot) {
842
981
  const pending = [];
843
982
  try {
@@ -933,6 +1072,10 @@ export async function doctorCommand(options = {}) {
933
1072
  // Documentation
934
1073
  section('Documentation');
935
1074
  record('docs', await checkDocSpecs(projectRoot));
1075
+ const rationaleCheck = checkInstallationRationale(meta);
1076
+ if (rationaleCheck) record('docs', rationaleCheck);
1077
+ const lintCheck = await checkDocLint(projectRoot);
1078
+ if (lintCheck) record('docs', lintCheck);
936
1079
  spacer();
937
1080
 
938
1081
  // Learnings
@@ -943,12 +1086,14 @@ export async function doctorCommand(options = {}) {
943
1086
  // Git Integration
944
1087
  section('Git Integration');
945
1088
  record('git', await checkGitignore(projectRoot));
1089
+ record('git', await checkOriginHead(projectRoot));
946
1090
  spacer();
947
1091
 
948
1092
  // Integrity
949
1093
  section('Integrity');
950
1094
  record('integrity', await checkHashIntegrity(projectRoot, meta));
951
1095
  record('integrity', await checkPendingReviewFiles(projectRoot));
1096
+ record('integrity', await checkStaleWorktrees(projectRoot));
952
1097
  spacer();
953
1098
 
954
1099
  // Exit code