The Claude Code subagent harness instructs spawned agents NOT to write report/summary/findings/analysis .md files — the parent reads the final text message. Verified live: analyzer-agent skipped Write entirely and returned the report inline, so analysis-report.md never landed on disk and the plan/interview/status phases would find nothing to read. New contract (orchestrator-writes pattern): analyzer-agent returns the complete report as its final message; the analyze command saves it verbatim to the session directory before presenting the summary. Same class exists in plan/feature-gap/optimize/scanner agent pairs — deliberately left for their own dogfood chunks (plan is judged as-is first per the pipeline sequence). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CTontYwY5JGS4nL2AuiASy
98 lines
3.5 KiB
Markdown
98 lines
3.5 KiB
Markdown
---
|
|
name: config-audit:analyze
|
|
description: Phase 2 - Generate analysis report with hierarchy map and issue detection
|
|
allowed-tools: Read, Write, Edit, Glob, Grep, Agent
|
|
model: opus
|
|
---
|
|
|
|
# Config-Audit: Analysis (Phase 2)
|
|
|
|
Generate comprehensive analysis report from discovery findings.
|
|
|
|
## Prerequisites
|
|
|
|
- Must have completed Phase 1 (discovery)
|
|
- Findings must exist in `~/.claude/config-audit/sessions/{session-id}/findings/`
|
|
|
|
## Arguments
|
|
|
|
- `$ARGUMENTS` may contain `--raw` to forward to the analyzer agent's instructions; in `--raw` mode the agent renders v5.0.0 verbatim severity prefiks instead of humanized `userActionLanguage` urgency phrasing.
|
|
|
|
## Implementation
|
|
|
|
### Step 1: Verify session state
|
|
|
|
Read `~/.claude/config-audit/sessions/{session-id}/state.yaml` using the Read tool and verify discovery phase completed. If not, tell the user: "Discovery hasn't been run yet. Start with `/config-audit discover` or just run `/config-audit` for a full audit."
|
|
|
|
### Step 2: Tell the user what's happening
|
|
|
|
```
|
|
## Analyzing Configuration
|
|
|
|
Reading your scan findings and generating a detailed analysis report...
|
|
This includes hierarchy mapping, conflict detection, and prioritized recommendations.
|
|
```
|
|
|
|
### Step 3: Spawn analyzer agent
|
|
|
|
Tell the user: **"Generating analysis (this takes about 30 seconds)..."**
|
|
|
|
```bash
|
|
RAW_FLAG=""
|
|
if echo "$ARGUMENTS" | grep -q -- "--raw"; then RAW_FLAG="--raw"; fi
|
|
```
|
|
|
|
```
|
|
Agent(subagent_type: "config-audit:analyzer-agent")
|
|
model: sonnet
|
|
prompt: |
|
|
Analyze all findings in: ~/.claude/config-audit/sessions/{session-id}/findings/
|
|
Mode: $RAW_FLAG (empty = humanized; "--raw" = v5.0.0 verbatim severity prefiks)
|
|
Generate comprehensive report covering:
|
|
1. Executive summary with key metrics, grouped by userImpactCategory
|
|
2. Hierarchy map visualization
|
|
3. Conflict detection across config layers
|
|
4. CLAUDE.md quality assessment
|
|
5. Security issues (secrets, permissions)
|
|
6. Top 10 prioritized recommendations — lead each item with the
|
|
finding's userActionLanguage ("Fix this now," "Fix soon,"
|
|
"Fix when convenient," "Optional cleanup," "FYI") rather than
|
|
raw severity. The humanizer already replaced jargon-heavy
|
|
title/description/recommendation strings with plain-language
|
|
equivalents — render them verbatim, do not paraphrase.
|
|
Return the complete report as your final message. Do not write it
|
|
to a file — the orchestrating command saves it to the session directory.
|
|
```
|
|
|
|
### Step 4: Save the report
|
|
|
|
The agent returns the complete report as its final message — the Claude Code
|
|
subagent harness instructs agents not to write report/analysis files themselves,
|
|
so the command must persist it. Write the returned report verbatim (no edits,
|
|
no truncation) to `~/.claude/config-audit/sessions/{session-id}/analysis-report.md`
|
|
using the Write tool. Downstream phases (`plan`, `interview`, `status`) read this file.
|
|
|
|
### Step 5: Present summary
|
|
|
|
After saving the report, show a brief summary:
|
|
|
|
```markdown
|
|
### Analysis Complete
|
|
|
|
Report generated with:
|
|
- {N} conflicts detected
|
|
- {N} optimization opportunities
|
|
- {N} security notes
|
|
- Top recommendation: {first recommendation}
|
|
|
|
Full report: `~/.claude/config-audit/sessions/{session-id}/analysis-report.md`
|
|
|
|
### What's next
|
|
|
|
- **`/config-audit plan`** — Turn findings into a prioritized action plan
|
|
- **`/config-audit fix`** — Auto-fix deterministic issues right away
|
|
```
|
|
|
|
### Step 6: Update state
|
|
|
|
Update `state.yaml` with `current_phase: "analyze"`, `next_phase: "plan"`.
|