all-for-claudecode 2.12.0 → 2.14.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 (72) hide show
  1. package/.claude-plugin/marketplace.json +24 -5
  2. package/.claude-plugin/plugin.json +15 -4
  3. package/README.md +14 -0
  4. package/agents/afc-appsec-expert.md +19 -26
  5. package/agents/afc-architect.md +9 -2
  6. package/agents/afc-backend-expert.md +16 -4
  7. package/agents/afc-design-expert.md +17 -7
  8. package/agents/afc-impl-worker.md +7 -1
  9. package/agents/afc-infra-expert.md +16 -6
  10. package/agents/afc-legal-expert.md +16 -18
  11. package/agents/afc-marketing-expert.md +15 -5
  12. package/agents/afc-pm-expert.md +16 -5
  13. package/agents/afc-pr-analyst.md +1 -1
  14. package/agents/afc-security.md +7 -2
  15. package/agents/afc-tech-advisor.md +18 -30
  16. package/docs/agent-authoring-guide.md +144 -0
  17. package/docs/context-management-harness.md +293 -0
  18. package/docs/orchestration-modes.md +228 -0
  19. package/docs/skill-authoring-guide.md +153 -0
  20. package/hooks/hooks.json +27 -2
  21. package/package.json +4 -3
  22. package/schemas/hooks.schema.json +1 -1
  23. package/schemas/marketplace.schema.json +6 -1
  24. package/schemas/plugin.schema.json +0 -4
  25. package/scripts/afc-pipeline-manage.sh +1 -0
  26. package/scripts/afc-post-compact.sh +54 -0
  27. package/scripts/afc-spec-guard.sh +7 -7
  28. package/scripts/afc-stop-failure.sh +46 -0
  29. package/scripts/afc-sync-cache.sh +8 -2
  30. package/scripts/afc-tdd-guard.sh +7 -5
  31. package/scripts/afc-user-prompt-submit.sh +43 -1
  32. package/scripts/pre-compact-checkpoint.sh +10 -0
  33. package/scripts/session-start-context.sh +10 -0
  34. package/skills/architect/SKILL.md +1 -9
  35. package/skills/auto/SKILL.md +228 -910
  36. package/skills/auto/skill-advisor.md +306 -0
  37. package/skills/checkpoint/SKILL.md +7 -1
  38. package/skills/clarify/SKILL.md +3 -2
  39. package/skills/consult/SKILL.md +30 -123
  40. package/skills/consult/peer-mode.md +61 -0
  41. package/skills/debug/SKILL.md +3 -21
  42. package/skills/ideate/SKILL.md +1 -77
  43. package/skills/ideate/brief-template.md +73 -0
  44. package/skills/implement/SKILL.md +68 -260
  45. package/skills/init/SKILL.md +79 -129
  46. package/skills/init/reference.md +55 -0
  47. package/skills/issue/SKILL.md +191 -0
  48. package/skills/launch/SKILL.md +5 -0
  49. package/skills/learner/SKILL.md +1 -25
  50. package/skills/learner/suggestion-format.md +49 -0
  51. package/skills/plan/SKILL.md +1 -5
  52. package/skills/pr-comment/SKILL.md +38 -51
  53. package/skills/principles/SKILL.md +3 -7
  54. package/skills/qa/SKILL.md +3 -14
  55. package/skills/release-notes/SKILL.md +6 -5
  56. package/skills/resolve/SKILL.md +162 -0
  57. package/skills/resolve/graphql.md +48 -0
  58. package/skills/resume/SKILL.md +10 -5
  59. package/skills/review/SKILL.md +56 -202
  60. package/skills/review/perspectives.md +118 -0
  61. package/skills/security/SKILL.md +4 -22
  62. package/skills/security/cross-boundary-verification.md +22 -0
  63. package/skills/setup/SKILL.md +40 -87
  64. package/skills/setup/conflict-detection.md +33 -0
  65. package/skills/spec/SKILL.md +6 -9
  66. package/skills/tasks/SKILL.md +47 -70
  67. package/skills/test/SKILL.md +4 -16
  68. package/skills/triage/SKILL.md +38 -85
  69. package/skills/triage/coupling-detection.md +13 -0
  70. package/skills/triage/pr-analysis-prompt.md +46 -0
  71. package/skills/validate/SKILL.md +24 -62
  72. package/skills/validate/validation-categories.md +39 -0
@@ -12,159 +12,111 @@ model: sonnet
12
12
 
13
13
  # /afc:init — Project Initial Setup
14
14
 
15
- > Creates project-local configuration files for the all-for-claudecode plugin.
16
- > Analyzes the project structure and generates config, rules, and profile.
17
- > This is a **project-local** operation — it only creates files under `.claude/`.
18
- > For global `~/.claude/CLAUDE.md` setup, use `/afc:setup` instead.
15
+ > Creates project-local configuration files (`.claude/afc.config.md`, `.claude/rules/afc-project.md`, `.claude/afc/project-profile.md`).
16
+ > **Project-local only** never touches `~/.claude/CLAUDE.md`. For global routing setup use `/afc:setup`.
19
17
 
20
- ## Important
21
-
22
- This skill is a **prompt-only skill** — there is NO `afc-init.sh` script.
23
- All steps below are instructions for the LLM to execute directly using its allowed tools (Read, Write, Bash, Glob).
24
- Do NOT attempt to run a shell script for this skill.
18
+ ## Project State (auto-loaded)
19
+ !`ls .claude/afc.config.md .claude/rules/afc-project.md .claude/selfish.config.md .claude/.selfish-* 2>/dev/null | head -20 || echo "[no existing afc files]"`
25
20
 
26
21
  ## Arguments
27
22
 
28
- - `$ARGUMENTS` — (optional) Additional context or hints for project analysis
23
+ - `$ARGUMENTS` — (optional) additional context or hints for project analysis
29
24
 
30
25
  ## Execution Steps
31
26
 
32
- ### 1. Legacy Migration Check
33
-
34
- Before anything else, detect and migrate v1.x (selfish-pipeline) artifacts:
35
-
36
- **A. Config file migration**
37
- - If `.claude/selfish.config.md` exists AND `.claude/afc.config.md` does NOT exist:
38
- - Rename: `mv .claude/selfish.config.md .claude/afc.config.md`
39
- - Print: `Migrated: selfish.config.md → afc.config.md`
40
- - If both exist: print warning, keep `afc.config.md`, skip migration
27
+ ### 1. Legacy Migration (v1.x → v2.x)
41
28
 
42
- **B. State file migration**
43
- - Glob `.claude/.selfish-*` — if any found:
44
- - Rename each: `.selfish-{x}` → `.afc-{x}`
45
- - Print: `Migrated: {count} state files (.selfish-* → .afc-*)`
29
+ Detect and migrate `selfish-pipeline` artifacts in one pass:
46
30
 
47
- **C. Artifact directory migration**
48
- - If `.claude/selfish/` exists AND `.claude/afc/` does NOT exist:
49
- - Rename: `mv .claude/selfish .claude/afc`
50
- - Print: `Migrated: .claude/selfish/.claude/afc/`
31
+ - `.claude/selfish.config.md` exists, `afc.config.md` does not → rename to `afc.config.md`
32
+ - `.claude/.selfish-*` files found rename each to `.afc-{x}`
33
+ - `.claude/selfish/` exists, `.claude/afc/` does not → rename to `.claude/afc/`
34
+ - `git tag -l 'selfish/*'`rename known patterns to `afc/` equivalent, delete the rest
51
35
 
52
- **D. Git tag cleanup**
53
- - Check `git tag -l 'selfish/*'`
54
- - If any found:
55
- - Known patterns (`selfish/pre-*`, `selfish/phase-*`): rename to `afc/` equivalent (`git tag afc/... selfish/... && git tag -d selfish/...`)
56
- - All remaining `selfish/*`: delete (`git tag -d`)
57
- - Print: `Migrated: {renamed} renamed, {deleted} deleted`
36
+ Print a single migration summary line. If nothing to migrate, skip silently.
58
37
 
59
38
  ### 2. Check for Existing Config
60
39
 
61
- If `.claude/afc.config.md` already exists:
62
- - Ask user: "Config file already exists. Do you want to overwrite it?"
40
+ If `.claude/afc.config.md` already exists and this is NOT a migration:
41
+ - Ask user: "Config file already exists. Overwrite?"
63
42
  - If declined: **abort**
64
43
 
65
44
  ### 3. Analyze Project Structure
66
45
 
67
- Analyze the project and auto-infer configuration. Use `$ARGUMENTS` as additional context if provided.
68
-
69
- **Step 1. Package Manager / Script Detection**
70
- - Read `package.json` extract CI-related commands from `scripts` field
71
- - Determine package manager from lockfile:
72
-
73
- | Lockfile | Package Manager |
74
- |----------|----------------|
75
- | `pnpm-lock.yaml` | pnpm |
76
- | `yarn.lock` | yarn |
77
- | `bun.lockb` or `bun.lock` | bun |
78
- | `package-lock.json` | npm |
79
-
80
- - If no lockfile: check `packageManager` field in `package.json`
81
- - Non-JS projects: check `pyproject.toml` (Python), `Cargo.toml` (Rust), `go.mod` (Go)
82
-
83
- > These detection rules are starting-point heuristics, not definitive. If a project uses a tool not listed here, the model should still detect it from context (e.g., `bun.lockb` for Bun, `deno.lock` for Deno). Always confirm the detected setup with the user before proceeding.
84
-
85
- **Step 2. Framework Detection**
86
- - Determine from `package.json` dependencies/devDependencies:
87
-
88
- | Dependency | Framework |
89
- |-----------|-----------|
90
- | `next` | Next.js (App Router if `app/` dir exists, else Pages Router) |
91
- | `nuxt` | Nuxt |
92
- | `@sveltejs/kit` | SvelteKit |
93
- | `@remix-run/react` | Remix |
94
- | `astro` | Astro |
95
- | `@angular/core` | Angular |
96
- | `vite` (alone) | Vite SPA |
97
- | `hono` | Hono |
98
- | `fastify` | Fastify |
99
- | `express` | Express |
100
-
101
- - Non-JS: `pyproject.toml` → Django/FastAPI/Flask, `Cargo.toml` → Rust project, `go.mod` → Go project
102
- - Presence of `tsconfig.json` → TypeScript indicator
103
-
104
- > This list covers common frameworks but is not exhaustive. For unlisted frameworks, infer from package.json dependencies, project structure, and configuration files. Present the detection result to the user for confirmation.
105
-
106
- **Step 3. Architecture Detection**
107
- - Analyze directory structure:
108
- - FSD: If the project's src/ directory contains a combination of FSD-characteristic directories (`features/`, `entities/`, `shared/`, `widgets/`, `pages/`, `processes/`, `app/`), assess whether the project follows FSD principles. Variant FSD structures (e.g., using `processes/` instead of `pages/`) should also be detected. Confirm with the user if the detection is uncertain.
109
- - `src/domain/`, `src/application/`, `src/infrastructure/` → Clean Architecture
110
- - `src/modules/` → Modular
111
- - Other → Layered
112
- - `paths` in `tsconfig.json` → extract path alias
113
-
114
- **Step 4. State / Styling / Testing / DB Detection**
115
- - State management: `zustand`, `@reduxjs/toolkit`, `@tanstack/react-query`, `swr`, `pinia`, `jotai`, `recoil`
116
- - Styling: `tailwindcss`, `styled-components`, `@emotion/react`, `sass`, CSS Modules (check for `*.module.css`)
117
- - Testing: `jest`, `vitest`, `playwright`, `@testing-library/*`, `cypress`
118
- - Linter: `.eslintrc*` / `eslint.config.*` / `biome.json` / `biome.jsonc`
119
- - DB/ORM: `prisma` (check `prisma/schema.prisma`), `drizzle-orm`, `typeorm`, `@prisma/client`
120
-
121
- **Step 5. Code Style Detection**
122
- - Check linter config → identify key rules
123
- - `strict` in `tsconfig.json` → strict mode
124
- - Read 2-3 existing code samples to verify naming patterns
46
+ Use `$ARGUMENTS` as additional context. Detection heuristics are in [`reference.md`](./reference.md) — consult it for package manager, framework, architecture, and tool detection tables.
47
+
48
+ 1. Read `package.json` extract CI scripts, detect package manager from lockfile
49
+ 2. Detect framework from `package.json` deps
50
+ 3. Detect architecture from directory structure + `tsconfig.json` paths
51
+ 4. Detect state/styling/testing/linter/DB tools
52
+ 5. Read 2–3 code samples to verify naming patterns
53
+
54
+ > Detection is best-effort. Present results to user for confirmation before writing files.
125
55
 
126
56
  ### 4. Generate Config File
127
57
 
128
- Generate `.claude/afc.config.md` in **free-form markdown** format:
58
+ Write `.claude/afc.config.md` based on template at `${CLAUDE_SKILL_DIR}/../../templates/afc.config.template.md`:
129
59
 
130
- 1. **CI Commands** section: YAML code block with `ci`, `gate`, `test` keys (fixed format, scripts parse these)
131
- 2. **Architecture** section: describe detected architecture style, layers, import rules, path aliases in free-form prose/lists
132
- 3. **Code Style** section: describe detected language, strictness, naming conventions, lint rules in free-form prose/lists
133
- 4. **Project Context** section: describe framework, state management, styling, testing, DB/ORM, risks, and any other relevant project characteristics in free-form prose/lists
60
+ 1. **CI Commands** YAML block with `ci`, `gate`, `test` keys (scripts parse this; format is fixed)
61
+ 2. **Architecture** detected pattern, layers, import rules, path aliases (free-form prose)
62
+ 3. **Code Style** language, strictness, naming, lint rules (free-form prose)
63
+ 4. **Project Context** framework, state, styling, testing, DB, risks (free-form prose)
134
64
 
135
- Reference `${CLAUDE_SKILL_DIR}/../../templates/afc.config.template.md` for the section structure.
136
- Write sections as natural descriptions — **no YAML code blocks** except for CI Commands.
137
- For items that cannot be inferred: note `TODO: Adjust for your project` inline.
138
- Save to `.claude/afc.config.md`.
65
+ No YAML blocks except CI Commands. Use `TODO: Adjust for your project` for unresolved items.
139
66
 
140
67
  ### 4.5. Generate Project Rules File
141
68
 
142
- Generate `.claude/rules/afc-project.md` a concise summary of project rules that Claude Code auto-loads for all conversations and sub-agents.
143
-
144
- 1. Create `.claude/rules/` directory if it does not exist
145
- 2. If `.claude/rules/afc-project.md` already exists:
146
- - If it contains `<!-- afc:auto-generated` marker: overwrite silently (auto-generated file, safe to regenerate)
147
- - If it does NOT contain the marker: ask user "Project rules file exists (user-managed). Overwrite with auto-generated version?" — skip if declined
148
- 3. Reference `${CLAUDE_SKILL_DIR}/../../templates/afc-project.template.md` for section structure
149
- 4. Fill in from the analysis performed in Step 3:
150
- - **Architecture**: pattern, key layers, import rules, path alias — concise bullet points
151
- - **Code Style**: language, naming conventions, lint rules — concise bullet points
152
- - **Project Context**: framework, state management, styling, testing, DB/ORM — concise bullet points
153
- 5. Include `<!-- afc:auto-generated — do not edit manually; regenerate with /afc:init -->` as the first line
154
- 6. Keep total length **under 30 lines** (excluding the marker comment) — rules only, no explanations
155
- 7. Save to `.claude/rules/afc-project.md`
156
- 8. Print: `Project rules: .claude/rules/afc-project.md (auto-loaded by Claude Code)`
69
+ Write `.claude/rules/afc-project.md` (auto-loaded by Claude Code for all sub-agents):
70
+
71
+ 1. Create `.claude/rules/` if not present
72
+ 2. If file exists with `<!-- afc:auto-generated` marker → overwrite silently
73
+ 3. If file exists without marker ask user before overwriting
74
+ 4. Use template `${CLAUDE_SKILL_DIR}/../../templates/afc-project.template.md`
75
+ 5. First line: `<!-- afc:auto-generated do not edit manually; regenerate with /afc:init -->`
76
+ 6. Max 30 lines (excluding marker) bullets only, no explanations
157
77
 
158
78
  ### 4.6. Generate Project Profile
159
79
 
160
- Generate `.claude/afc/project-profile.md` for expert consultation agents:
80
+ Write `.claude/afc/project-profile.md` for expert consultation agents:
81
+
82
+ 1. Create `.claude/afc/` if not present
83
+ 2. If file already exists → skip (do not overwrite)
84
+ 3. Fill Stack/Architecture/Domain from Step 3 analysis; leave Team/Scale/Constraints as placeholders
85
+ 4. Use template `${CLAUDE_SKILL_DIR}/../../templates/project-profile.template.md`
86
+
87
+ ### 4.7. Update CLAUDE.md with Compact Instructions
88
+
89
+ Append a `# Compact instructions` section to the project's `CLAUDE.md` (create if not present):
90
+
91
+ 1. Check if `CLAUDE.md` already contains `# Compact instructions` → if yes, skip silently
92
+ 2. Append the following block to `CLAUDE.md`:
93
+
94
+ ```markdown
95
+ # Compact instructions
96
+ When compacting, always preserve:
97
+ - Active pipeline feature name and current phase
98
+ - File Change Map from plan.md (file paths + task assignments)
99
+ - All unresolved ESCALATE items with their options
100
+ - context.md contents (spec summary + plan decisions + advisor results)
101
+ - Changed files list and CI/test pass/fail status
102
+ - Current task progress (completed/total)
103
+ ```
104
+
105
+ This ensures auto-compact retains critical pipeline state.
106
+
107
+ ### 4.8. Recommend Context Window Configuration
108
+
109
+ If the project CLAUDE.md does not already contain auto-compact configuration guidance, append:
110
+
111
+ ```markdown
112
+ # Context window configuration (recommended)
113
+ # Add to .claude/settings.json or .claude/settings.local.json:
114
+ # { "env": { "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "500000" } }
115
+ # This treats the window as 500k for compaction — the remaining 500k is reserve headroom.
116
+ # Combined with the compact instructions above, this gives you full control over when compaction happens.
117
+ ```
161
118
 
162
- 1. Create `.claude/afc/` directory if it does not exist
163
- 2. If `.claude/afc/project-profile.md` already exists: skip (do not overwrite)
164
- 3. If not exists: generate from the detected project information using `${CLAUDE_SKILL_DIR}/../../templates/project-profile.template.md` as the structure
165
- - Fill in Stack, Architecture, and Domain fields from the analysis in Step 3
166
- - Leave Team, Scale, and Constraints as template placeholders for user to fill
167
- 4. Print: `Project profile: .claude/afc/project-profile.md (review and adjust team/scale/domain fields)`
119
+ Note: This is informational only. Do NOT modify settings.json just add as a comment in CLAUDE.md for user awareness.
168
120
 
169
121
  ### 5. Final Output
170
122
 
@@ -173,6 +125,7 @@ all-for-claudecode project init complete
173
125
  ├─ Config: .claude/afc.config.md
174
126
  ├─ Rules: .claude/rules/afc-project.md (auto-loaded)
175
127
  ├─ Profile: .claude/afc/project-profile.md
128
+ ├─ Compact instructions: CLAUDE.md updated
176
129
  ├─ Framework: {detected framework}
177
130
  ├─ Architecture: {detected style}
178
131
  ├─ Package Manager: {detected manager}
@@ -183,8 +136,5 @@ all-for-claudecode project init complete
183
136
 
184
137
  ## Notes
185
138
 
186
- - **Idempotent**: safe to run multiple times. Existing config prompts for overwrite confirmation; auto-generated rules are silently regenerated.
187
- - **Project-local only**: this skill only creates files under `.claude/`. It never touches `~/.claude/CLAUDE.md`. For global routing setup, use `/afc:setup`.
188
- - **Overwrite caution**: If config file already exists, always confirm with user.
189
- - **Inference limits**: Auto-inference is best-effort. User may need to review and adjust.
190
- - **`.claude/` directory**: Created automatically if it does not exist.
139
+ - **Idempotent**: existing auto-generated rules are silently regenerated; config prompts for confirmation.
140
+ - **Inference limits**: Auto-detection is best-effort review and adjust after generation.
@@ -0,0 +1,55 @@
1
+ # /afc:init — Detection Reference
2
+
3
+ ## Package Manager Detection
4
+
5
+ | Lockfile | Package Manager |
6
+ |----------|----------------|
7
+ | `pnpm-lock.yaml` | pnpm |
8
+ | `yarn.lock` | yarn |
9
+ | `bun.lockb` or `bun.lock` | bun |
10
+ | `package-lock.json` | npm |
11
+ | `deno.lock` | deno |
12
+
13
+ Fallback: check `packageManager` field in `package.json`.
14
+ Non-JS: `pyproject.toml` (Python), `Cargo.toml` (Rust), `go.mod` (Go).
15
+
16
+ ## Framework Detection
17
+
18
+ Determine from `package.json` dependencies/devDependencies:
19
+
20
+ | Dependency | Framework |
21
+ |-----------|-----------|
22
+ | `next` | Next.js (App Router if `app/` dir, else Pages Router) |
23
+ | `nuxt` | Nuxt |
24
+ | `@sveltejs/kit` | SvelteKit |
25
+ | `@remix-run/react` | Remix |
26
+ | `astro` | Astro |
27
+ | `@angular/core` | Angular |
28
+ | `vite` (alone) | Vite SPA |
29
+ | `hono` | Hono |
30
+ | `fastify` | Fastify |
31
+ | `express` | Express |
32
+
33
+ Non-JS: `pyproject.toml` → Django/FastAPI/Flask, `Cargo.toml` → Rust, `go.mod` → Go.
34
+ Unlisted: infer from project structure + confirm with user.
35
+
36
+ ## Architecture Detection
37
+
38
+ | Pattern | Signals |
39
+ |---------|---------|
40
+ | FSD | `src/` contains ≥3 of: `features/`, `entities/`, `shared/`, `widgets/`, `pages/`, `app/` |
41
+ | Clean Architecture | `src/domain/`, `src/application/`, `src/infrastructure/` |
42
+ | Modular | `src/modules/` |
43
+ | Layered | Default fallback |
44
+
45
+ Also extract path aliases from `tsconfig.json` `paths`.
46
+
47
+ ## Tool Detection
48
+
49
+ | Tool | Detection Signal |
50
+ |------|-----------------|
51
+ | State: zustand/redux/jotai/recoil/pinia/swr/react-query | `package.json` dep |
52
+ | Styling: tailwindcss/styled-components/@emotion/sass | `package.json` dep; CSS Modules: `*.module.css` |
53
+ | Testing: jest/vitest/playwright/cypress/@testing-library | `package.json` dep |
54
+ | Linter: eslint/biome | `.eslintrc*`, `eslint.config.*`, `biome.json` |
55
+ | DB/ORM: prisma/drizzle-orm/typeorm | `package.json` dep; prisma: check `prisma/schema.prisma` |
@@ -0,0 +1,191 @@
1
+ ---
2
+ name: afc:issue
3
+ description: "Analyze GitHub issue and create actionable document — use when the user asks to analyze a GitHub issue, investigate a bug report, understand requirements from an issue, triage incoming requests, or inspect a specific issue number"
4
+ argument-hint: "<GitHub issue URL, owner/repo#number, #number, or number>"
5
+ allowed-tools:
6
+ - Read
7
+ - Grep
8
+ - Glob
9
+ - Bash
10
+ - WebFetch
11
+ - Write
12
+ model: sonnet
13
+ ---
14
+
15
+ # /afc:issue — GitHub Issue Analysis
16
+
17
+ > Analyzes a single GitHub issue (title, body, labels, comments, attached images) and produces a structured analysis document.
18
+ > Searches the codebase for related files and suggests the appropriate next afc skill (debug, spec, or auto).
19
+
20
+ ## Pre-fetch
21
+
22
+ !`gh --version >/dev/null 2>&1 && gh auth status >/dev/null 2>&1 && echo "GH_OK" || echo "GH_UNAVAILABLE"`
23
+
24
+ ## Arguments
25
+
26
+ - `$ARGUMENTS` — (required) One of:
27
+ - Issue number: `123` or `#123`
28
+ - GitHub URL: `https://github.com/owner/repo/issues/123`
29
+ - Cross-repo: `owner/repo#123`
30
+
31
+ ## Execution Steps
32
+
33
+ ### 1. Prerequisites Check
34
+
35
+ If the pre-fetch returned `GH_UNAVAILABLE`:
36
+ - Output: `[afc:issue] Error: GitHub CLI (gh) is not installed or not authenticated. Install from https://cli.github.com/ and run 'gh auth login'.`
37
+ - **Abort immediately.**
38
+
39
+ ### 2. Parse Input
40
+
41
+ Determine the input format and extract owner, repo, and issue number:
42
+
43
+ 1. **GitHub URL** (`https://github.com/{owner}/{repo}/issues/{number}`): extract from path, set `GH_REPO_FLAG="--repo {owner}/{repo}"`
44
+ 2. **Cross-repo** (`{owner}/{repo}#{number}`): split on `#`, set `GH_REPO_FLAG="--repo {owner}/{repo}"`
45
+ 3. **Local number** (`123` or `#123`): strip leading `#`, set `GH_REPO_FLAG=""` (use current repo from git remote)
46
+
47
+ ### 3. Collect Issue Data
48
+
49
+ ```bash
50
+ gh issue view {number} {GH_REPO_FLAG} --json number,title,body,labels,author,comments,createdAt,state,url
51
+ ```
52
+
53
+ If the command fails → output error and **abort**.
54
+
55
+ Parse and extract: `TITLE`, `BODY`, `LABELS`, `AUTHOR`, `COMMENTS`, `CREATED_AT`, `STATE`, `URL`.
56
+
57
+ ### 4. Analyze Attached Images
58
+
59
+ Extract image URLs from the issue body (skip images inside code block fences):
60
+ - Markdown: `![alt]({url})`
61
+ - HTML: `<img src="{url}">`
62
+
63
+ For each URL: fetch with WebFetch, analyze content (error messages, UI screenshots, console output, stack traces), tag results with `[Image Analysis]`. Record failures as `[Image unavailable: {url}]`.
64
+
65
+ If no images: note `No attached media found.`
66
+
67
+ ### 5. Analyze Comments
68
+
69
+ If more than 20 comments: analyze only the **most recent 20** and note `"Analyzed 20 of {N} comments (most recent)"`.
70
+
71
+ Extract: reproduction steps, error logs, workarounds, maintainer responses, related issue/PR references.
72
+
73
+ ### 6. Search Codebase
74
+
75
+ Extract keywords from title, body, and comments:
76
+ - Error messages (quoted strings, stack trace patterns)
77
+ - Function/class/module names, file paths, project-specific technical terms
78
+
79
+ Search with Grep and Glob. Record matching files with line numbers and relevance reason. If no matches: `No related code found in current codebase.`
80
+
81
+ ### 7. Classify Issue
82
+
83
+ **Type** — choose the strongest matching signal:
84
+
85
+ | Signal | Type |
86
+ |--------|------|
87
+ | Error messages, stack traces, "broken", "doesn't work", reproduction steps | **Bug Report** |
88
+ | "Add", "support", "new feature", "would be nice", "enhancement" | **Feature Request** |
89
+ | "How to", "is it possible", "what is", "documentation" | **Question** |
90
+ | "Improve", "refactor", "better", "optimize", existing feature modification | **Enhancement** |
91
+
92
+ **Severity** — based on production impact, not code location:
93
+
94
+ | Level | Criteria |
95
+ |-------|---------|
96
+ | **Critical** | Data loss, security vulnerability, application crash, or complete feature unavailability with no workaround |
97
+ | **High** | Core functionality broken; workaround exists but is painful or undocumented |
98
+ | **Medium** | Non-critical functionality impacted; reasonable workaround available, or significant UX degradation |
99
+ | **Low** | Cosmetic issue, minor UX friction, or improvement with no functional impact |
100
+
101
+ **Estimated Scope:**
102
+
103
+ | Level | Criteria |
104
+ |-------|---------|
105
+ | **Small** | 1–2 files — typo, config change, isolated bug fix |
106
+ | **Medium** | 3–5 files — feature addition, moderate refactor |
107
+ | **Large** | 6+ files — cross-cutting concern, architectural change |
108
+
109
+ ### 8. Determine Next Step
110
+
111
+ | Type | Suggested Next Step |
112
+ |------|-------------------|
113
+ | Bug Report | `/afc:debug "{issue title summary}"` |
114
+ | Feature Request | `/afc:spec "{feature description}"` or `/afc:auto "{feature description}"` |
115
+ | Question | Reply to issue — provide answer or point to documentation |
116
+ | Enhancement | `/afc:spec "{enhancement description}"` |
117
+ | Insufficient info | Reply to issue — request: {specific missing information} |
118
+
119
+ ### 9. Save Analysis Document
120
+
121
+ ```bash
122
+ mkdir -p .claude/afc/issues
123
+ ```
124
+
125
+ If `.claude/afc/issues/{number}-*.md` exists → ask user: "Overwrite existing analysis for issue #{number}?"
126
+
127
+ Generate slug from title: lowercase, replace non-alphanumeric with `-`, truncate to 40 chars.
128
+
129
+ Write to `.claude/afc/issues/{number}-{slug}.md`:
130
+
131
+ ```markdown
132
+ # Issue #{number}: {title}
133
+
134
+ > Analyzed: {YYYY-MM-DD}
135
+ > Source: {url}
136
+ > Labels: {labels, comma-separated}
137
+ > Author: {author}
138
+ > State: {Open/Closed}
139
+
140
+ ## Summary
141
+
142
+ {2-4 sentence summary including context from body, comments, and images — not just a restatement of the title.}
143
+
144
+ ## Attached Media Analysis
145
+
146
+ {If images exist:}
147
+ > [Image Analysis] Below is AI interpretation of attached media.
148
+
149
+ - **Image 1** ({filename or "screenshot"}): {description}
150
+
151
+ {If no images:}
152
+ No attached media found.
153
+
154
+ ## Codebase Impact
155
+
156
+ - `{path}:{line}` — {why this file is related}
157
+
158
+ {If no related files:}
159
+ No related code found in current codebase.
160
+
161
+ ## Classification
162
+
163
+ - **Type**: {Bug Report | Feature Request | Question | Enhancement}
164
+ - **Severity**: {Critical | High | Medium | Low}
165
+ - **Estimated Scope**: {Small (1-2 files) | Medium (3-5) | Large (6+)}
166
+
167
+ ## Suggested Next Step
168
+
169
+ - [ ] {Primary suggestion with full command} — {reason}
170
+ - [ ] {Secondary suggestion if applicable} — {reason}
171
+ ```
172
+
173
+ ### 10. Output Summary
174
+
175
+ ```
176
+ Issue analyzed
177
+ ├─ Issue: #{number} — {title}
178
+ ├─ Type: {classification}
179
+ ├─ Severity: {severity}
180
+ ├─ Related files: {count}
181
+ ├─ Document: .claude/afc/issues/{number}-{slug}.md
182
+ └─ Next step: {primary suggestion}
183
+ ```
184
+
185
+ ## Notes
186
+
187
+ - **Read-only**: Does not modify any code. Only creates an analysis document.
188
+ - **Image analysis is best-effort**: AI interpretation of screenshots may be imprecise — `[Image Analysis]` tag makes this explicit.
189
+ - **Not part of auto pipeline**: Standalone skill, invoked manually.
190
+ - **Relationship to triage**: `afc:triage` handles bulk analysis; `afc:issue` handles deep individual analysis.
191
+ - **Comment limit**: Max 20 comments analyzed (most recent prioritized).
@@ -25,6 +25,11 @@ model: sonnet
25
25
  - `"auto"` — auto-detects version from package.json/Cargo.toml/pyproject.toml
26
26
  - Not specified: prompts for version
27
27
 
28
+ ## Git Context (auto-loaded)
29
+
30
+ !`git describe --tags --abbrev=0 2>/dev/null || echo "[NO_TAGS]"`
31
+ !`git log $(git describe --tags --abbrev=0 2>/dev/null || echo "")..HEAD --pretty=format:"%h %s" --no-merges 2>/dev/null || git log --pretty=format:"%h %s" --no-merges`
32
+
28
33
  ## Execution Steps
29
34
 
30
35
  ### 1. Detect Project Context
@@ -73,31 +73,7 @@ For each candidate rule:
73
73
 
74
74
  ### 4. Present Suggestions
75
75
 
76
- Show clustered suggestions to user, most impactful first. Present the most impactful suggestions first. If there are many high-confidence patterns, present them all rather than artificially capping. If most are low-confidence, present fewer. Let relevance and confidence drive the count, not a fixed limit.
77
-
78
- ```markdown
79
- ## Learned Patterns ({N} pending, showing top {M})
80
-
81
- ### 1. [Style] Prefer const over let
82
- - Detected: 3 times across 2 sessions
83
- - Confidence: HIGH
84
- - Proposed rule:
85
- ```
86
- Prefer `const` for variable declarations. Use `let` only when reassignment is required.
87
- ```
88
- - Target: `.claude/rules/afc-learned.md` (universal)
89
- - [Approve] [Edit] [Skip] [Reject permanently]
90
-
91
- ### 2. [Naming] No default exports in React components
92
- - Detected: 2 times (pipeline: auth-feature)
93
- - Confidence: HIGH
94
- - Proposed rule:
95
- ```
96
- In React component files (*.tsx), use named exports only. Avoid default exports.
97
- ```
98
- - Target: `.claude/rules/afc-learned.md` (universal — scope expressed in prose)
99
- - [Approve] [Edit] [Skip] [Reject permanently]
100
- ```
76
+ Show clustered suggestions to user, most impactful first. Let relevance and confidence drive the count, not a fixed limit. See [suggestion-format.md](suggestion-format.md) for the presentation template.
101
77
 
102
78
  Wait for user response on each suggestion.
103
79
 
@@ -0,0 +1,49 @@
1
+ # Suggestion Presentation Format
2
+
3
+ Present each clustered pattern suggestion in this format:
4
+
5
+ ```markdown
6
+ ## Learned Patterns ({N} pending, showing top {M})
7
+
8
+ ### 1. [{Rule type}] {Short title}
9
+ - Detected: {count} times across {sessions} sessions
10
+ - Confidence: {HIGH / MEDIUM / LOW}
11
+ - Proposed rule:
12
+ ```
13
+ {Concise, actionable rule text}
14
+ ```
15
+ - Target: `.claude/rules/afc-learned.md` ({scope: universal / file-type-specific})
16
+ - [Approve] [Edit] [Skip] [Reject permanently]
17
+ ```
18
+
19
+ ## Example
20
+
21
+ ```markdown
22
+ ### 1. [Style] Prefer const over let
23
+ - Detected: 3 times across 2 sessions
24
+ - Confidence: HIGH
25
+ - Proposed rule:
26
+ ```
27
+ Prefer `const` for variable declarations. Use `let` only when reassignment is required.
28
+ ```
29
+ - Target: `.claude/rules/afc-learned.md` (universal)
30
+ - [Approve] [Edit] [Skip] [Reject permanently]
31
+
32
+ ### 2. [Naming] No default exports in React components
33
+ - Detected: 2 times (pipeline: auth-feature)
34
+ - Confidence: HIGH
35
+ - Proposed rule:
36
+ ```
37
+ In React component files (*.tsx), use named exports only. Avoid default exports.
38
+ ```
39
+ - Target: `.claude/rules/afc-learned.md` (universal — scope expressed in prose)
40
+ - [Approve] [Edit] [Skip] [Reject permanently]
41
+ ```
42
+
43
+ ## User Response Handling
44
+
45
+ Wait for user response on each suggestion:
46
+ - **Approve**: promote to rules file
47
+ - **Edit**: user modifies the rule text, then promote
48
+ - **Skip**: remove from queue, do not promote
49
+ - **Reject permanently**: remove from queue + add to suppression list
@@ -139,11 +139,7 @@ Run the critic loop until convergence. Safety cap: 5 passes.
139
139
  4. **Constraint propagation**: every item in spec.md `Constraints` section is addressed in Risk & Mitigation or Implementation Context `Must NOT`. Report: `{M}/{N} constraints propagated`.
140
140
  5. **Acceptance anchor alignment**: Implementation Context `Acceptance Anchors` faithfully reflect spec.md's acceptance scenarios (no omissions, no misinterpretations).
141
141
 
142
- **On FAIL**: auto-fix and continue to next pass.
143
- **On ESCALATE**: pause, present options to user, apply choice, resume.
144
- **On DEFER**: record reason, mark criterion clean, continue.
145
- **On CONVERGE**: `✓ Critic converged ({N} passes, {M} fixes, {E} escalations)`
146
- **On SAFETY CAP**: `⚠ Critic safety cap ({N} passes). Review recommended.`
142
+ Follow verdict handling and output format per `docs/critic-loop-rules.md`.
147
143
 
148
144
  ### 5.5. ADR Recording (optional)
149
145