claude-code-scanner 1.0.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 (65) hide show
  1. package/DOCUMENTATION.md +1210 -0
  2. package/LICENSE +21 -0
  3. package/README.md +306 -0
  4. package/bin/cli.js +305 -0
  5. package/package.json +43 -0
  6. package/template/.claude/agents/api-builder.md +64 -0
  7. package/template/.claude/agents/architect.md +92 -0
  8. package/template/.claude/agents/debugger.md +69 -0
  9. package/template/.claude/agents/explorer.md +71 -0
  10. package/template/.claude/agents/frontend.md +61 -0
  11. package/template/.claude/agents/infra.md +66 -0
  12. package/template/.claude/agents/product-owner.md +73 -0
  13. package/template/.claude/agents/qa-lead.md +102 -0
  14. package/template/.claude/agents/reviewer.md +77 -0
  15. package/template/.claude/agents/security.md +81 -0
  16. package/template/.claude/agents/team-lead.md +128 -0
  17. package/template/.claude/agents/tester.md +72 -0
  18. package/template/.claude/docs/agent-error-protocol.md +89 -0
  19. package/template/.claude/docs/best-practices.md +93 -0
  20. package/template/.claude/docs/commands-template.md +73 -0
  21. package/template/.claude/docs/conflict-resolution-protocol.md +82 -0
  22. package/template/.claude/docs/context-budget.md +54 -0
  23. package/template/.claude/docs/execution-metrics-protocol.md +105 -0
  24. package/template/.claude/docs/flow-engine.md +475 -0
  25. package/template/.claude/docs/smithery-setup.md +51 -0
  26. package/template/.claude/docs/task-record-schema.md +196 -0
  27. package/template/.claude/hooks/drift-detector.js +143 -0
  28. package/template/.claude/hooks/execution-report.js +114 -0
  29. package/template/.claude/hooks/notify-approval.js +30 -0
  30. package/template/.claude/hooks/post-compact-recovery.js +68 -0
  31. package/template/.claude/hooks/post-edit-format.js +43 -0
  32. package/template/.claude/hooks/pre-compact-save.js +94 -0
  33. package/template/.claude/hooks/protect-files.js +39 -0
  34. package/template/.claude/hooks/session-start.js +76 -0
  35. package/template/.claude/hooks/stop-failure-handler.js +77 -0
  36. package/template/.claude/hooks/tool-failure-tracker.js +54 -0
  37. package/template/.claude/hooks/track-file-changes.js +34 -0
  38. package/template/.claude/hooks/validate-bash.js +34 -0
  39. package/template/.claude/manifest.json +22 -0
  40. package/template/.claude/profiles/backend.md +34 -0
  41. package/template/.claude/profiles/devops.md +36 -0
  42. package/template/.claude/profiles/frontend.md +34 -0
  43. package/template/.claude/rules/context-budget.md +34 -0
  44. package/template/.claude/scripts/verify-setup.js +210 -0
  45. package/template/.claude/settings.json +154 -0
  46. package/template/.claude/skills/context-check/SKILL.md +112 -0
  47. package/template/.claude/skills/execution-report/SKILL.md +229 -0
  48. package/template/.claude/skills/generate-environment/SKILL.md +128 -0
  49. package/template/.claude/skills/generate-environment/additional-skills.md +276 -0
  50. package/template/.claude/skills/generate-environment/artifact-templates.md +386 -0
  51. package/template/.claude/skills/generate-environment/domain-agents.md +202 -0
  52. package/template/.claude/skills/impact-analysis/SKILL.md +17 -0
  53. package/template/.claude/skills/metrics/SKILL.md +19 -0
  54. package/template/.claude/skills/progress-report/SKILL.md +27 -0
  55. package/template/.claude/skills/rollback/SKILL.md +75 -0
  56. package/template/.claude/skills/scan-codebase/SKILL.md +59 -0
  57. package/template/.claude/skills/scan-codebase/deep-scan-instructions.md +101 -0
  58. package/template/.claude/skills/scan-codebase/tech-markers.md +87 -0
  59. package/template/.claude/skills/setup-smithery/SKILL.md +38 -0
  60. package/template/.claude/skills/sync/SKILL.md +239 -0
  61. package/template/.claude/skills/task-tracker/SKILL.md +40 -0
  62. package/template/.claude/skills/validate-setup/SKILL.md +30 -0
  63. package/template/.claude/skills/workflow/SKILL.md +333 -0
  64. package/template/.claude/templates/README.md +42 -0
  65. package/template/CLAUDE.md +67 -0
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: rollback
3
+ description: Rollback a failed deployment, revert code changes, or undo a workflow phase. Use when deployment fails, regressions are found, or a phase needs to be undone.
4
+ user-invocable: true
5
+ disable-model-invocation: true
6
+ allowed-tools: Read, Bash, Grep, Glob
7
+ argument-hint: "[deploy|code|phase] [task-id] [--to-commit SHA]"
8
+ ---
9
+
10
+ # Rollback: $ARGUMENTS
11
+
12
+ ## Commands
13
+ - `/rollback deploy TASK-id` — Rollback a failed deployment
14
+ - `/rollback code TASK-id` — Revert all code changes from a task
15
+ - `/rollback phase TASK-id --to-phase N` — Undo work back to phase N
16
+ - `/rollback code --to-commit SHA` — Revert to a specific commit
17
+
18
+ ## Deploy Rollback
19
+ 1. **Identify**: Read task record for deployment details (Phase 11)
20
+ 2. **Verify**: Confirm which deployment to rollback (staging/production)
21
+ 3. **Execute**: Run rollback procedure:
22
+ ```bash
23
+ # If merge-based deployment:
24
+ git revert --no-commit HEAD
25
+ git commit -m "revert: rollback TASK-{id} deployment"
26
+ # Push and trigger deploy pipeline
27
+ ```
28
+ 4. **Health Check**: Verify service is healthy after rollback
29
+ 5. **Update Task**: Set status back to appropriate phase
30
+
31
+ ## Code Rollback
32
+ 1. **Identify**: Read changes log (`.claude/tasks/TASK-{id}_changes.log`) for all modified files
33
+ 2. **Branch State**: Check if changes are committed, staged, or unstaged
34
+ 3. **Revert Strategy**:
35
+ - If PR not merged: close PR, delete branch
36
+ - If committed but not pushed: `git reset` to pre-task commit
37
+ - If pushed but not merged: revert commits on branch
38
+ - If merged: create revert commit on main
39
+ 4. **Verify**: Run test suite to confirm clean state
40
+ 5. **Update Task**: Set status to CANCELLED or route back to earlier phase
41
+
42
+ ## Phase Rollback
43
+ 1. **Identify**: Read task record for phase history
44
+ 2. **Determine Scope**: What artifacts were created in the target phase range
45
+ 3. **Revert Files**: Undo file changes from phases N+1 through current
46
+ 4. **Preserve**: Keep task record timeline (add rollback event)
47
+ 5. **Reset State**: Update task status to target phase
48
+ 6. **Re-enter**: Resume workflow from target phase
49
+
50
+ ## Safety Checks
51
+ - NEVER rollback without confirming with user first
52
+ - NEVER force-push to main/master
53
+ - ALWAYS create a revert commit rather than rewriting history
54
+ - ALWAYS run tests after rollback to verify clean state
55
+ - ALWAYS update the task record with rollback event in timeline
56
+
57
+ ## Output Format
58
+ ### Rollback Report
59
+ - **Type:** deploy / code / phase
60
+ - **Task:** TASK-{id}
61
+ - **Rolled Back From:** phase/commit/deployment
62
+ - **Rolled Back To:** phase/commit/state
63
+ - **Files Reverted:** list
64
+ - **Test Suite:** PASS/FAIL after rollback
65
+ - **Status:** SUCCESS / PARTIAL / FAILED
66
+
67
+ ### HANDOFF
68
+ ```
69
+ HANDOFF:
70
+ from: /rollback
71
+ to: @team-lead
72
+ reason: rollback [complete/failed]
73
+ artifacts: [revert commit, task record]
74
+ context: [what was rolled back and current state]
75
+ ```
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: scan-codebase
3
+ description: Deep-scan any codebase to fingerprint tech stack, architecture, conventions, and domain knowledge. Use when setting up Claude Code for an existing project.
4
+ user-invocable: true
5
+ context: fork
6
+ allowed-tools: Read, Grep, Glob, Bash, Agent
7
+ effort: high
8
+ argument-hint: "[path-to-project]"
9
+ ---
10
+
11
+ # Scan Codebase: $ARGUMENTS
12
+
13
+ **Reference files in this skill directory:**
14
+ - `tech-markers.md` — complete list of 100+ technology marker files to check
15
+ - `deep-scan-instructions.md` — detailed instructions for backend, frontend, architecture, and domain scans
16
+
17
+ Run 6 scanning agents using the Agent tool. Launch all 6 in a single message for maximum parallelism (Claude Code supports multiple Agent tool calls in one response). Each agent runs in its own subagent context and returns a structured report. If any agent fails (maxTurns or error), continue with the remaining agents — partial scan results are still valuable.
18
+
19
+ ## Agent 1: Technology Fingerprinter
20
+ Rapid scan of marker files to identify everything present.
21
+
22
+ Check for ALL of these (read actual file contents, not just names):
23
+
24
+ **Languages:** package.json, requirements.txt, go.mod, Cargo.toml, pom.xml, *.csproj, Gemfile, composer.json, pubspec.yaml, mix.exs, build.sbt, CMakeLists.txt
25
+
26
+ **Frameworks:** Read dependency files for React/Next/Remix, Vue/Nuxt, Angular, Svelte/SvelteKit, Django, Flask, FastAPI, Spring, Rails, Laravel, Express, NestJS, ASP.NET, Gin/Echo/Fiber
27
+
28
+ **Databases:** prisma/schema.prisma, ormconfig, alembic/, migrations/, mongoose, redis, elasticsearch in dependencies
29
+
30
+ **API:** openapi.yaml, *.graphql, *.proto, @trpc in package.json
31
+
32
+ **Testing:** jest.config, vitest.config, cypress.config, playwright.config, pytest.ini, *_test.go, spec/
33
+
34
+ **Infra:** Dockerfile, docker-compose, *.tf, k8s/, serverless.yml, .github/workflows/, .gitlab-ci.yml
35
+
36
+ **Monorepo:** nx.json, turbo.json, lerna.json, pnpm-workspace.yaml
37
+
38
+ For every marker found, READ the file to extract exact versions, scripts, and config.
39
+
40
+ Output `TECH_MANIFEST` JSON with: project_name, project_type, languages[], frontend{}, backend{}, database{}, infrastructure{}, ci_cd{}, testing{}, monorepo{}, package_manager.
41
+
42
+ ## Agent 2: Directory Structure Scanner
43
+ Map full tree up to 4 levels. Classify each directory: source, tests, config, docs, scripts, build output, generated (DO NOT MODIFY), vendor (skip).
44
+ Identify: where handlers live, where services live, where models live, where types live, where tests live.
45
+
46
+ ## Agent 3: Backend Deep Scanner
47
+ Read actual source files. Identify: runtime version, framework patterns (middleware, DI, routing), API layer (every route, validation, response format, auth), database layer (ORM, migrations, queries, transactions), background jobs, external integrations, logging, error handling.
48
+
49
+ ## Agent 4: Frontend Deep Scanner
50
+ Read 3-5 actual components. Identify: framework + meta-framework, rendering mode (CSR/SSR/SSG), routing pattern, state management, component architecture (props, hooks, styling), build/bundle config, TypeScript config, API communication layer.
51
+
52
+ ## Agent 5: Architecture Mapper
53
+ Trace a request end-to-end. Map: module boundaries, dependency graph, communication patterns, deployment topology, security architecture (auth flow, authz model), shared code.
54
+
55
+ ## Agent 6: Domain & Convention Extractor
56
+ Read 20+ files to establish patterns. Extract: naming conventions (variables, files, directories, endpoints, DB tables), code style beyond linter config, error handling patterns, git conventions (from git log), TODO/FIXME/HACK comments, existing AI config (.cursorrules, CLAUDE.md).
57
+
58
+ ## Output
59
+ Combine all 6 reports into a single structured document saved to `.claude/scan-results.md`.
@@ -0,0 +1,101 @@
1
+ # Deep Scan Instructions
2
+
3
+ ## Backend Deep Scan (Agent 3)
4
+ Read actual source files, not just configs.
5
+
6
+ ### Runtime & Framework
7
+ - Exact language/runtime version (from config, CI, Dockerfile)
8
+ - Module system (ESM, CommonJS, mixed)
9
+ - Framework patterns: middleware chain, DI, router structure, error handlers
10
+ - Custom abstractions on top of framework
11
+
12
+ ### API Layer
13
+ - READ every route file — list all endpoints (method + path)
14
+ - Request validation: Zod, Joi, Pydantic, class-validator
15
+ - Response format: envelope, direct, HAL, JSON:API
16
+ - Error format: codes, messages, status codes
17
+ - Pagination: cursor, offset, keyset
18
+ - Auth: JWT/session/OAuth — read the actual auth middleware
19
+ - Authorization: RBAC/ABAC — read actual permission checks
20
+
21
+ ### Database Layer
22
+ - ORM, connection pooling, migration strategy
23
+ - Query patterns: raw SQL, query builder, repository, active record
24
+ - Transaction handling, caching strategy, read replicas
25
+
26
+ ### Background & External
27
+ - Job queues: Bull, Celery, Sidekiq
28
+ - Events: pub/sub, domain events, message brokers
29
+ - Third-party APIs, SDKs, file storage, search engines
30
+
31
+ ### Security & Observability
32
+ - Password hashing, token validation, input sanitization
33
+ - Logging library, format, levels, request tracing
34
+ - Metrics, health checks, error tracking
35
+
36
+ ---
37
+
38
+ ## Frontend Deep Scan (Agent 4)
39
+ Read 3-5 actual components.
40
+
41
+ ### Framework & Rendering
42
+ - Exact version, rendering mode (CSR/SSR/SSG/ISR)
43
+ - Component flavor: hooks, Composition API, class-based, signals
44
+
45
+ ### Routing & State
46
+ - Router library, route definition pattern (file-based/config-based)
47
+ - State: Redux/Zustand/Pinia/NgRx/Context
48
+ - Server state: React Query/SWR/Apollo
49
+ - Form state: React Hook Form/Formik
50
+
51
+ ### Component Architecture
52
+ - File structure, naming, organization pattern
53
+ - Prop patterns, common component patterns (compound, HOC, hooks)
54
+ - Design system / UI library
55
+
56
+ ### Styling & Build
57
+ - CSS Modules/Tailwind/styled-components/SCSS
58
+ - Bundler config, env var prefix (NEXT_PUBLIC_, VITE_)
59
+ - TypeScript strict mode, path aliases
60
+
61
+ ### Testing & API
62
+ - Unit: Jest/Vitest + testing-library patterns
63
+ - E2E: Cypress/Playwright patterns
64
+ - HTTP client, API layer abstraction, error/loading handling
65
+
66
+ ---
67
+
68
+ ## Architecture Scan (Agent 5)
69
+ - Trace a request end-to-end through all layers
70
+ - Map module boundaries and dependency graph
71
+ - Identify circular dependencies
72
+ - Classify: monolith/modular monolith/microservices
73
+ - Document deployment topology, CDN, load balancer
74
+ - Map auth flow step-by-step
75
+ - Identify shared code across modules/packages
76
+
77
+ ---
78
+
79
+ ## Domain & Convention Scan (Agent 6)
80
+ Read 20+ files to establish patterns.
81
+
82
+ ### Naming (per context)
83
+ - Variables, functions, classes/types, files, directories
84
+ - Test names, API endpoints, DB tables/columns, env vars
85
+
86
+ ### Code Style (beyond linter)
87
+ - Import ordering/grouping, export style
88
+ - Ternary vs if-else preference, arrow vs function
89
+ - Async patterns: await, .then(), callbacks
90
+
91
+ ### Conventions
92
+ - Error types/classes, how errors propagate
93
+ - Git commit format (from last 20 commits), branch naming
94
+ - Documentation: JSDoc/docstring coverage, README structure
95
+
96
+ ### Gotchas
97
+ - ALL TODO/FIXME/HACK comments with context
98
+ - Workarounds with explanatory comments
99
+ - Dead code, deprecated features still present
100
+ - Implicit ordering dependencies, magic values
101
+ - Existing AI config: .cursorrules, CLAUDE.md, .aider
@@ -0,0 +1,87 @@
1
+ # Technology Marker Reference
2
+
3
+ ## Package Managers & Languages
4
+ - **JavaScript/TypeScript:** package.json, yarn.lock, pnpm-lock.yaml, package-lock.json, bun.lockb, .npmrc, .nvmrc, .node-version
5
+ - **Python:** requirements.txt, Pipfile, pyproject.toml, setup.py, setup.cfg, poetry.lock, conda.yml, tox.ini
6
+ - **Go:** go.mod, go.sum
7
+ - **Rust:** Cargo.toml, Cargo.lock
8
+ - **Java/Kotlin:** pom.xml, build.gradle, build.gradle.kts, settings.gradle, gradlew, .mvn/
9
+ - **C#/.NET:** *.csproj, *.sln, Directory.Build.props, nuget.config, global.json
10
+ - **Ruby:** Gemfile, Gemfile.lock, .ruby-version
11
+ - **PHP:** composer.json, composer.lock, artisan
12
+ - **Dart/Flutter:** pubspec.yaml
13
+ - **Swift:** Package.swift, *.xcodeproj, Podfile
14
+ - **Elixir:** mix.exs
15
+ - **Scala:** build.sbt
16
+ - **C/C++:** CMakeLists.txt, Makefile, configure.ac, meson.build, vcpkg.json
17
+
18
+ ## Frameworks (read config to confirm version)
19
+ - **React:** package.json → "react", "next", "gatsby", "remix"
20
+ - **Vue:** package.json → "vue", "nuxt"
21
+ - **Angular:** angular.json, package.json → "@angular/core"
22
+ - **Svelte:** svelte.config.js, package.json → "svelte", "@sveltejs/kit"
23
+ - **Django:** manage.py, settings.py, wsgi.py, asgi.py
24
+ - **Flask:** app.py/wsgi.py → "from flask"
25
+ - **FastAPI:** Python files → "from fastapi"
26
+ - **Spring Boot:** pom.xml/build.gradle → "spring-boot"
27
+ - **Rails:** config/routes.rb, Rakefile, bin/rails
28
+ - **Laravel:** artisan, config/app.php, routes/web.php
29
+ - **Express:** package.json → "express"
30
+ - **NestJS:** package.json → "@nestjs/core", nest-cli.json
31
+ - **ASP.NET:** *.csproj → "Microsoft.AspNetCore"
32
+ - **Gin/Echo/Fiber:** go.mod → "gin-gonic", "labstack/echo", "gofiber"
33
+
34
+ ## Databases & ORMs
35
+ - **Prisma:** prisma/schema.prisma
36
+ - **TypeORM:** ormconfig.ts/json, "typeorm" in package.json
37
+ - **SQLAlchemy:** "from sqlalchemy" in Python files
38
+ - **Sequelize:** "sequelize" in package.json, .sequelizerc
39
+ - **Drizzle:** drizzle.config.ts, "drizzle-orm" in package.json
40
+ - **Mongoose:** "mongoose" in package.json
41
+ - **Migrations:** migrations/, db/migrate/, alembic/, prisma/migrations/
42
+
43
+ ## APIs
44
+ - **OpenAPI:** openapi.yaml, swagger.json
45
+ - **GraphQL:** *.graphql, "graphql"/"apollo" in dependencies
46
+ - **gRPC:** *.proto, buf.yaml
47
+ - **tRPC:** "@trpc" in package.json
48
+
49
+ ## Testing
50
+ - **Jest:** jest.config.*, "jest" in package.json
51
+ - **Vitest:** vitest.config.*, "vitest" in package.json
52
+ - **Cypress:** cypress.config.*, cypress/
53
+ - **Playwright:** playwright.config.*, "@playwright/test" in package.json
54
+ - **Pytest:** pytest.ini, conftest.py, [tool.pytest] in pyproject.toml
55
+ - **Go test:** *_test.go files
56
+ - **RSpec:** spec/, .rspec
57
+
58
+ ## Infrastructure
59
+ - **Docker:** Dockerfile, docker-compose.yml, .dockerignore
60
+ - **Kubernetes:** k8s/, kustomization.yaml, Chart.yaml
61
+ - **Terraform:** *.tf, .terraform/
62
+ - **Serverless:** serverless.yml, sam-template.yaml
63
+ - **CI/CD:** .github/workflows/, .gitlab-ci.yml, Jenkinsfile, .circleci/config.yml
64
+
65
+ ## Monorepo
66
+ - **Nx:** nx.json
67
+ - **Turborepo:** turbo.json
68
+ - **Lerna:** lerna.json
69
+ - **pnpm:** pnpm-workspace.yaml
70
+ - **Yarn:** "workspaces" in package.json
71
+ - **Bazel:** WORKSPACE, BUILD
72
+
73
+ ## TECH_MANIFEST Output Schema
74
+ ```json
75
+ {
76
+ "project_name": "", "project_type": "monorepo|fullstack|backend|frontend|library|cli|mobile",
77
+ "languages": [{"name": "", "version": "", "detected_from": ""}],
78
+ "frontend": {"exists": false, "framework": "", "version": "", "ui_library": "", "state_management": "", "routing": "", "styling": "", "bundler": "", "ssr": false, "root_dir": "", "entry_point": "", "dev_command": "", "build_command": "", "test_command": ""},
79
+ "backend": {"exists": false, "framework": "", "version": "", "language": "", "runtime_version": "", "api_style": "REST|GraphQL|gRPC|tRPC|mixed", "root_dir": "", "entry_point": "", "dev_command": "", "build_command": "", "test_command": ""},
80
+ "database": {"type": "", "orm": "", "migration_tool": "", "migration_dir": "", "schema_file": ""},
81
+ "infrastructure": {"containerized": false, "orchestration": "", "iac": "", "cloud": ""},
82
+ "ci_cd": {"platform": "", "config_file": ""},
83
+ "testing": {"unit": "", "integration": "", "e2e": "", "coverage_tool": ""},
84
+ "monorepo": {"tool": "", "packages": []},
85
+ "package_manager": ""
86
+ }
87
+ ```
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: setup-smithery
3
+ description: Install Smithery skills and MCP servers matching the project tech stack. Use after /generate-environment.
4
+ user-invocable: true
5
+ disable-model-invocation: true
6
+ allowed-tools: Read, Bash, Grep
7
+ ---
8
+
9
+ # Setup Smithery: $ARGUMENTS
10
+
11
+ Read `.claude/scan-results.md` for tech stack. Install matching skills and MCP servers.
12
+
13
+ ## Always Install
14
+ ```bash
15
+ smithery skill add anthropics/skill-creator --agent claude-code
16
+ smithery skill add anthropics/frontend-design --agent claude-code
17
+ smithery skill add anthropics/webapp-testing --agent claude-code
18
+ smithery skill add anthropics/mcp-builder --agent claude-code
19
+ smithery skill add anthropics/pdf --agent claude-code
20
+ ```
21
+
22
+ ## Conditional on Tech Stack
23
+ - React/Expo → `smithery skill search "react"`, Expo skills
24
+ - shadcn/ui → shadcn skill
25
+ - Playwright → anthropics/webapp-testing
26
+ - Security code → Trail of Bits security skills
27
+ - Docker/K8s → `smithery skill search "docker kubernetes"`
28
+ - GitHub Actions → `smithery skill search "github actions"`
29
+
30
+ ## MCP Servers (scope to agents, max 5)
31
+ - GitHub → @api-builder, @infra
32
+ - PostgreSQL/MongoDB → @api-builder
33
+ - Playwright → @frontend
34
+ - AWS/GCP → @infra
35
+ - Slack/Sentry → global (if used)
36
+
37
+ ## After Install
38
+ Run `/context-check` to verify under 60%. Remove low-priority items if over budget.
@@ -0,0 +1,239 @@
1
+ ---
2
+ name: sync
3
+ description: Detect drift between the Claude Code environment and the actual codebase. Updates CLAUDE.md, agents, skills, rules, hooks, and settings when roles change, dependencies update, or project structure evolves.
4
+ user-invocable: true
5
+ context: fork
6
+ allowed-tools: Read, Edit, Write, Bash, Grep, Glob, Agent
7
+ argument-hint: "[--check|--fix|--full-rescan] [--component agents|skills|rules|hooks|claude-md|all]"
8
+ effort: high
9
+ ---
10
+
11
+ # Sync: $ARGUMENTS
12
+
13
+ Detect and resolve drift between the Claude Code environment (`.claude/`) and the actual project codebase.
14
+
15
+ ## Commands
16
+ - `/sync` or `/sync --check` — Detect drift only, report what's stale (no changes)
17
+ - `/sync --fix` — Detect drift and auto-fix all stale files
18
+ - `/sync --fix --component agents` — Fix only agent files
19
+ - `/sync --fix --component claude-md` — Fix only CLAUDE.md
20
+ - `/sync --full-rescan` — Complete re-scan + regenerate everything (like fresh install)
21
+
22
+ ## When to Run
23
+ - After adding/removing dependencies (`npm install`, `pip install`, etc.)
24
+ - After adding/removing agents, skills, hooks, or rules manually
25
+ - After major refactors that change file structure
26
+ - After team role changes (new agent types needed, roles removed)
27
+ - Periodically (weekly recommended) to catch gradual drift
28
+ - At workflow Phase 1 (Task Intake) — automatic drift check before starting work
29
+
30
+ ---
31
+
32
+ ## Step 1: Read Current Manifest
33
+ Read `.claude/manifest.json` if it exists. This tracks what was last generated and from what state.
34
+
35
+ If manifest doesn't exist, create one from current state (first-time sync).
36
+
37
+ ## Step 2: Detect Drift (8 categories)
38
+
39
+ ### 2a: Agent Drift
40
+ Compare `.claude/agents/*.md` against actual state:
41
+ - **Added agents:** .md files in agents/ that aren't in manifest
42
+ - **Removed agents:** manifest entries with no matching .md file
43
+ - **Modified agents:** .md files newer than manifest timestamp
44
+ - **CLAUDE.md agent table stale:** agents listed in CLAUDE.md vs actual agent files
45
+ - **Workflow agent team stale:** agents in workflow SKILL.md agent table vs actual files
46
+ - **commands-template stale:** agent @-mentions in commands doc vs actual files
47
+
48
+ Check each agent for compliance:
49
+ - Has required fields? (name, description, tools, model, maxTurns, effort, memory, HANDOFF, Limitations)
50
+ - Read-only agents have permissionMode: plan + disallowedTools?
51
+ - Dev agents have isolation: worktree?
52
+
53
+ ### 2b: Skill Drift
54
+ Compare `.claude/skills/*/SKILL.md` against actual state:
55
+ - **Added skills:** SKILL.md files not in manifest
56
+ - **Removed skills:** manifest entries with no matching skill dir
57
+ - **Modified skills:** SKILL.md files newer than manifest timestamp
58
+ - **Missing frontmatter:** skills without name/description/user-invocable
59
+ - **Missing context:fork:** heavy skills (>30 lines) without fork
60
+ - **Stale cross-references:** skills referenced in generate-environment but not in skills dir
61
+
62
+ ### 2c: Hook Drift
63
+ Compare `.claude/hooks/*.js` against settings.json:
64
+ - **Orphan hooks:** .js files not registered in any settings.json hook event
65
+ - **Missing hooks:** settings.json references a .js file that doesn't exist
66
+ - **New hooks not registered:** .js files added to hooks/ but not in settings.json
67
+
68
+ ### 2d: Rule Drift
69
+ Compare `.claude/rules/*.md` against codebase:
70
+ - **Rules referencing non-existent paths:** `paths:` globs that match zero files
71
+ - **Missing rules for new directories:** new source directories with no matching rule
72
+ - **Stale content:** rules mentioning frameworks/patterns no longer in the project
73
+
74
+ ### 2e: CLAUDE.md Drift
75
+ Compare root CLAUDE.md against actual project state:
76
+ - **Tech stack stale:** versions in CLAUDE.md vs package.json/go.mod/Cargo.toml/etc.
77
+ - **Commands stale:** build/test/lint commands in CLAUDE.md vs actual scripts
78
+ - **Agent table stale:** agents listed vs actual .claude/agents/ files
79
+ - **Key paths stale:** referenced directories/files that no longer exist
80
+ - **Line count over limit:** CLAUDE.md exceeds 200 lines
81
+
82
+ ### 2f: Settings Drift
83
+ Compare `.claude/settings.json` against hooks and project state:
84
+ - **Hook events missing:** supported events without any hooks registered
85
+ - **Permission patterns stale:** allow/deny patterns referencing commands that don't exist
86
+ - **Missing env vars:** project requires env vars not documented in settings
87
+
88
+ ### 2g: Dependency/Tech Stack Drift
89
+ Compare project dependencies against what was scanned:
90
+ - Read package.json, go.mod, Cargo.toml, requirements.txt, etc.
91
+ - Compare current dependency versions vs what's in CLAUDE.md tech stack
92
+ - Detect: new frameworks added, frameworks removed, major version bumps
93
+ - Flag: if a new framework means a new agent or rule is needed
94
+
95
+ ### 2h: Project Structure Drift
96
+ Compare directory structure against what was scanned:
97
+ - New source directories not covered by rules
98
+ - Removed directories still referenced in rules/CLAUDE.md
99
+ - New test directories not in testing rules
100
+ - New config files not in infrastructure rules
101
+
102
+ ---
103
+
104
+ ## Step 3: Generate Drift Report
105
+
106
+ Output drift report to stdout AND save to `.claude/reports/drift-report.md`:
107
+
108
+ ```markdown
109
+ # Drift Report — {ISO timestamp}
110
+
111
+ ## Summary
112
+ | Category | Status | Drift Items |
113
+ |----------|--------|-------------|
114
+ | Agents | {OK/STALE} | {count} changes |
115
+ | Skills | {OK/STALE} | {count} changes |
116
+ | Hooks | {OK/STALE} | {count} changes |
117
+ | Rules | {OK/STALE} | {count} changes |
118
+ | CLAUDE.md | {OK/STALE} | {count} changes |
119
+ | Settings | {OK/STALE} | {count} changes |
120
+ | Tech Stack | {OK/STALE} | {count} changes |
121
+ | Structure | {OK/STALE} | {count} changes |
122
+ | **Overall** | **{IN_SYNC/DRIFT_DETECTED}** | **{total}** |
123
+
124
+ ## Details
125
+ ### Agents
126
+ - [ADDED] new-agent.md found in agents/ but not in manifest
127
+ - [REMOVED] old-agent.md in manifest but no file on disk
128
+ - [STALE] CLAUDE.md lists 12 agents but 14 agent files exist
129
+ - [COMPLIANCE] agent-x.md missing memory: project field
130
+
131
+ ### Skills
132
+ - [ADDED] new-skill/SKILL.md found but not in manifest
133
+ - [STALE] workflow/SKILL.md modified after last sync
134
+ ...
135
+
136
+ ### CLAUDE.md
137
+ - [STALE] Tech stack: react 18.2.0 in CLAUDE.md but 19.0.0 in package.json
138
+ - [STALE] Agent table: 12 agents listed but 14 files exist
139
+ - [STALE] Command: "npm test" in CLAUDE.md but "vitest" in package.json scripts
140
+ ...
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Step 4: Auto-Fix (when `--fix` flag is present)
146
+
147
+ ### Fix Agent Drift
148
+ 1. **New agents:** Add to CLAUDE.md agent table, workflow agent team, commands-template
149
+ 2. **Removed agents:** Remove from CLAUDE.md, workflow, commands-template
150
+ 3. **Non-compliant agents:** Add missing fields (memory: project, HANDOFF, Limitations)
151
+ 4. **CLAUDE.md stale:** Regenerate agent table section from actual agent files
152
+
153
+ ### Fix Skill Drift
154
+ 1. **New skills:** Add to generate-environment skill list, commands-template
155
+ 2. **Removed skills:** Remove from generate-environment, commands-template
156
+ 3. **Missing frontmatter:** Add name/description from directory name
157
+ 4. **Missing fork:** Add `context: fork` to skills >30 lines
158
+
159
+ ### Fix Hook Drift
160
+ 1. **Orphan hooks:** Register in settings.json under appropriate event (guess from filename)
161
+ 2. **Missing hooks:** Remove from settings.json OR create placeholder .js
162
+ 3. **Unregistered hooks:** Add to settings.json with appropriate matcher
163
+
164
+ ### Fix Rule Drift
165
+ 1. **Dead path rules:** Update `paths:` to match current directory structure
166
+ 2. **New directories:** Create new rule files for uncovered source dirs
167
+ 3. **Stale content:** Flag for manual review (can't auto-update domain rules)
168
+
169
+ ### Fix CLAUDE.md
170
+ 1. **Tech stack:** Read dependency files, update version numbers
171
+ 2. **Commands:** Read package.json scripts (or equivalent), update Quick Commands section
172
+ 3. **Agent table:** Regenerate from actual `.claude/agents/*.md` files
173
+ 4. **Key paths:** Verify each path exists, remove dead paths, add new entry points
174
+ 5. **@imports:** Verify imported files exist
175
+
176
+ ### Fix Settings
177
+ 1. **Missing hook registrations:** Add entries for unregistered hooks
178
+ 2. **Dead permissions:** Remove allow/deny patterns for non-existent commands
179
+
180
+ ---
181
+
182
+ ## Step 5: Update Manifest
183
+
184
+ After sync (check or fix), update `.claude/manifest.json`:
185
+
186
+ ```json
187
+ {
188
+ "last_sync": "ISO timestamp",
189
+ "last_scan": "ISO timestamp of last /scan-codebase",
190
+ "environment_version": "1.0.0",
191
+ "agents": {
192
+ "team-lead.md": { "hash": "sha256...", "modified": "ISO timestamp" },
193
+ "architect.md": { "hash": "sha256...", "modified": "ISO timestamp" }
194
+ },
195
+ "skills": {
196
+ "workflow": { "hash": "sha256...", "modified": "ISO timestamp" }
197
+ },
198
+ "hooks": {
199
+ "session-start.js": { "hash": "sha256...", "registered_in": ["SessionStart"] }
200
+ },
201
+ "rules": {
202
+ "context-budget.md": { "hash": "sha256...", "paths": ["**/*"] }
203
+ },
204
+ "tech_stack": {
205
+ "package.json": { "hash": "sha256...", "modified": "ISO timestamp" },
206
+ "go.mod": null
207
+ },
208
+ "claude_md": {
209
+ "hash": "sha256...",
210
+ "line_count": 62,
211
+ "agents_listed": 12
212
+ },
213
+ "project_structure": {
214
+ "source_dirs": ["src/", "lib/"],
215
+ "test_dirs": ["tests/", "__tests__/"],
216
+ "config_files": ["package.json", "tsconfig.json"]
217
+ }
218
+ }
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Step 6: Output Summary
224
+
225
+ ```
226
+ SYNC RESULT
227
+ ===========
228
+ Status: {IN_SYNC / DRIFT_DETECTED / FIXED}
229
+ Categories: {N}/8 in sync
230
+ Drift: {N} items found
231
+ Fixed: {N} items auto-fixed (if --fix)
232
+ Manual: {N} items need manual review
233
+
234
+ Next: {recommendation}
235
+ - "All synced. No action needed."
236
+ - "Run /sync --fix to auto-repair N items."
237
+ - "N items need manual review — see .claude/reports/drift-report.md"
238
+ - "Major drift detected. Consider /sync --full-rescan."
239
+ ```
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: task-tracker
3
+ description: Track task progress across all SDLC phases. Use when asking about task status, progress, blockers, or needing reports.
4
+ user-invocable: true
5
+ allowed-tools: Read, Write, Edit, Bash, Grep, Glob
6
+ context: fork
7
+ argument-hint: "create|status|update|report|dashboard|history|blockers|metrics [args]"
8
+ ---
9
+
10
+ # Task Tracker: $ARGUMENTS
11
+
12
+ ## Commands
13
+ - `/task-tracker create "title"` — Create task in `.claude/tasks/TASK-{id}.md`
14
+ - `/task-tracker status [TASK-id]` — Dashboard or single task status
15
+ - `/task-tracker update TASK-id phase=N status=STATE` — Update state
16
+ - `/task-tracker update TASK-id blocked="reason" owner="who"` — Log blocker
17
+ - `/task-tracker update TASK-id unblocked` — Clear blocker
18
+ - `/task-tracker report [TASK-id]` — Full detail report
19
+ - `/task-tracker dashboard` — Visual dashboard
20
+ - `/task-tracker history [TASK-id]` — Timeline of events
21
+ - `/task-tracker blockers` — All open blockers
22
+ - `/task-tracker metrics` — Aggregate performance
23
+
24
+ ## Task States
25
+ BACKLOG → INTAKE → ANALYZING → DESIGNING → APPROVED → DEVELOPING → DEV_TESTING → REVIEWING → CI_PENDING → QA_TESTING → QA_SIGNOFF → BIZ_SIGNOFF → TECH_SIGNOFF → DEPLOYING → MONITORING → CLOSED
26
+ (+ BLOCKED, CANCELLED, ON_HOLD at any state)
27
+
28
+ ## Task Record (`.claude/tasks/TASK-{id}.md`)
29
+ Frontmatter: id, title, type, scope, complexity, priority, status, branch, pr, created, updated
30
+ Sections: Current Status, Timeline (every event with timestamp/agent/duration), Phase Details (1-12), Blockers Log, Decision Log, Risk Register
31
+
32
+ ## Bug Tracking
33
+ Bugs logged as: BUG-{task_id}-{number} with severity (P0-P4), steps to reproduce, expected/actual, evidence, status tracking (OPEN → IN_PROGRESS → FIXED → QA_VERIFY → VERIFIED/REOPENED → CLOSED)
34
+
35
+ ## Reports (use /progress-report for stakeholder-specific)
36
+ - dev: files changed, test results, agent activity, commands
37
+ - qa: what changed, test scenarios, regression risks, environment
38
+ - business: acceptance criteria status, progress bar, ETA
39
+ - management: portfolio table, health indicators, blockers
40
+ - executive: status light, key metrics, trends
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: validate-setup
3
+ description: Validate the generated Claude Code environment meets all standards. Use after /generate-environment completes.
4
+ user-invocable: true
5
+ context: fork
6
+ allowed-tools: Read, Bash, Grep, Glob
7
+ ---
8
+
9
+ # Validate Setup
10
+
11
+ ## Checks
12
+ 1. **CLAUDE.md** — exists, under 150 lines (recommended under 200), no `{placeholder}` values
13
+ 2. **Rules** — each under 50 lines, has `paths:` frontmatter for scoped rules
14
+ 3. **Agents (12 required)** — each has name/description/tools, SDLC role agents present (team-lead, architect, product-owner, qa-lead), read-only agents have `permissionMode: plan` and `disallowedTools`, dev agents have `isolation: worktree`, all have `memory: project`, all have structured output format and HANDOFF block and Limitations section
15
+ 4. **Skills** — each has name/description, heavy ones have `context: fork`, user-facing have `argument-hint`, dangerous ones have `disable-model-invocation: true`
16
+ 5. **Settings** — valid JSON, has `permissions.defaultMode`, `permissions.allow`, `permissions.deny`, `env`, all hooks registered
17
+ 6. **Hooks** — Node.js scripts exist and are valid, all hooks in settings.json point to existing files
18
+ 7. **Templates** — extracted from real code (not generic)
19
+ 8. **.gitignore** — includes settings.local.json, tasks/, reports/
20
+ 9. **Commands work** — build, test, lint commands actually execute
21
+ 10. **Context budget** — total always-loaded under 200 lines, run `/context`
22
+ 11. **Handoff protocol** — workflow skill includes structured HANDOFF format
23
+ 12. **Loop tracking** — task record schema includes Loop State section
24
+
25
+ ## Run verification script
26
+ ```bash
27
+ node .claude/scripts/verify-setup.js
28
+ ```
29
+
30
+ Report results as PASS/FAIL/WARN with specific fix instructions for failures.