This skill guides interactive codebase analysis with documented exploration, multi-perspective reasoning, and traceable decisions to convert findings into
npx playbooks add skill catlog22/claude-code-workflow --skill analyze-with-file
Interactive collaborative analysis with documented discussion process. Records understanding evolution, facilitates multi-round Q&A, and uses inline search + external research for deep exploration.
Core flow: Topic → Explore → Discuss → Refine → Conclude → Next Step
Auto mode (-y): Auto-confirm exploration decisions, use recommended angles, skip interactive scoping.
| Flag | Default | Description |
|------|---------|-------------|
| -y, --yes | false | Auto-confirm all decisions |
| --continue | false | Continue existing session |
| --depth | standard | quick / standard / deep |
Session ID: ANL-{YYYY-MM-DD}-{slug}
topic.toLowerCase() → keep [a-z0-9\u4e00-\u9fa5], replace rest with -, max 40 chars{projectRoot}/.workflow/.analysis/ANL-{date}-{slug}/
├── discussion.md # Single source of truth: rounds, decisions, conclusions, synthesis
├── state.json # Session state: config, confidence, quality tracking
├── exploration-codebase.json # Codebase exploration: files, patterns, constraints
├── research.json # External research: best practices, pitfalls, sources
└── handoff.json # Structured handoff (only on "执行任务")
| File | When Created | Purpose |
|------|-------------|---------|
| discussion.md | Phase 1 | All analysis content: session metadata, round-by-round findings, multi-perspective synthesis, decisions, intent coverage, conclusions, recommendations. Overwritten sections: ## Current Understanding. Appended sections: ## Discussion Timeline. |
| state.json | Phase 0 | Machine-readable: current round, dimension scores, confidence history, quality tracking (pressure pass, challenge modes, stall counter), exploration metadata. Updated every round. |
| exploration-codebase.json | Phase 2 | Codebase context: project_type, relevant_files[{path, relevance, summary, dimensions[]}], patterns[{pattern, files, description}], constraints[], integration_points[{location, description}], key_findings[], _metadata{timestamp, exploration_scope} |
| research.json | Phase 2 | External research: findings[{finding, detail, confidence, source_url}], best_practices[{practice, rationale, source}], alternatives[{option, pros, cons, verdict}], pitfalls[{issue, mitigation, source}], codebase_gaps[{gap, current_approach, recommended_approach}], sources[{title, url, key_takeaway}] |
| handoff.json | Phase 4 | Only on "执行任务": source, session_id, session_folder, summary, implementation_scope[{objective, rationale, priority, target_files[], acceptance_criteria[], change_summary}], code_anchors[], key_files[], key_findings[], decision_context[], exploration_artifacts{exploration_codebase, research} — keys align with workflow-lite-plan artifactMapping |
---
Phase 0: Session Setup
├─ Parse topic, flags, generate session ID
├─ Detect project root (git rev-parse --show-toplevel || pwd)
├─ Create session folder (or detect existing → continue)
├─ Initialize state.json + discussion.md
└─ functions.update_plan([phase-1..phase-4, next-step])
Phase 1: Topic Understanding
├─ Identify analysis dimensions from topic keywords
├─ Scope with user: focus, perspectives (1-4), depth
├─ Generate initial questions from dimensions
└─ Write initial sections to discussion.md
Phase 2: Exploration
├─ Load project specs (ccw spec load)
├─ Codebase search → exploration-codebase.json
├─ External research via web.run → research.json
├─ Multi-perspective analysis → write to discussion.md
├─ Context budget gate (>30 files → rank + trim)
├─ Initial intent coverage check
└─ Baseline confidence scoring → state.json
Phase 3: Interactive Discussion (max 5 rounds)
├─ Present findings + confidence + weakest dimension
├─ User direction: Deepen / Research / Adjust / Complete
├─ Cumulative context: always include prior findings
├─ Record-before-continue: write to discussion.md BEFORE state update
├─ Quality mechanisms:
│ ├─ Pressure pass (mandatory ≥1 before Phase 4)
│ ├─ Challenge injection (auto, round ≥2)
│ ├─ Stall detection (2 consecutive no-progress rounds)
│ └─ Re-score confidence → state.json
├─ Pre-synthesis readiness gate (on "Complete")
├─ Intent drift check (round ≥2)
└─ Update discussion.md: append round + overwrite Current Understanding
Phase 4: Synthesis & Terminal Gate
├─ Intent Coverage Verification (mandatory gate)
├─ Findings → Recommendations Traceability (mandatory gate)
├─ Write synthesis + conclusions to discussion.md
├─ Recommendation review with user
└─ Terminal gate: 执行任务 → handoff.json | 产出Issue | 完成
---
{{ARGUMENTS}} for topic, flags (--depth, --continue, -y)git rev-parse --show-toplevel 2>/dev/null || pwdANL-{date}-{slug}, session folder: {projectRoot}/.workflow/.analysis/{sessionId}mkdir -p {sessionFolder}state.json:{
"session_id": "ANL-{date}-{slug}",
"topic": "...",
"depth": "standard",
"dimensions": [],
"perspectives": [],
"focus_areas": [],
"current_round": 0,
"current_phase": "setup",
"confidence": {
"dimensions": {},
"overall": 0,
"weakest": null,
"history": []
},
"quality": {
"pressure_pass_done": false,
"challenge_modes_used": [],
"stall_counter": 0,
"last_findings_count": 0,
"readiness_gate_passed": false,
"residual_risks": []
}
}
functions.update_plan([
{ id: "phase-1", title: "Phase 1: Topic Understanding", status: "in_progress" },
{ id: "phase-2", title: "Phase 2: Exploration & Research", status: "pending" },
{ id: "phase-3", title: "Phase 3: Interactive Discussion", status: "pending" },
{ id: "phase-4", title: "Phase 4: Synthesis & Conclusion", status: "pending" },
{ id: "next-step", title: "GATE: Post-Completion Next Step", status: "pending" }
])
---
Match topic keywords against [Analysis Dimensions](#analysis-dimensions). If multiple match, include all. If none match, default to "architecture" + "implementation".
Single functions.request_user_input call with up to 3 questions (constraint: 1-4 questions, 2-4 options each):
Question 1 — Focus areas (multiSelect: true):
Question 2 — Perspectives (multiSelect: true):
Max 4 perspectives. Single perspective is default.
Question 3 — Depth (multiSelect: false):
Write the full initial template (see [discussion.md Structure](#discussionmd-structure)):
Update state.json with dimensions, perspectives, focus_areas, depth. Mark phase-1 completed, phase-2 in_progress.
---
All exploration done inline — no agent delegation.
Detect project type:
package.json → nodejs | go.mod → golang | Cargo.toml → rust | pyproject.toml → python | pom.xml → java | src/ exists → generic | else → noneIf codebase detected, load project metadata:
functions.exec_command('ccw spec load --category exploration')functions.exec_command('ccw spec load --category debug').workflow/specs/*.md for project conventionsSearch using: Grep, Glob, Read, mcp__ace-tool__search_context
Focus on: modules/components relevant to topic, code patterns/structure, integration points, config/dependencies.
Write findings to exploration-codebase.json with full schema:
project_type: detected typerelevant_files[]: {path, relevance, summary, dimensions[]}patterns[]: {pattern, files, description}constraints[]: architectural constraints foundintegration_points[]: {location, description}key_findings[]: main insights from code search_metadata: {timestamp, exploration_scope}Trigger condition: dimensions include architecture|comparison|decision|performance|security, OR topic matches best practice|pattern|vs|compare|approach|standard|library|framework.
Skip for purely internal codebase questions (e.g., "how does module X work").
Execute up to 3 web.run queries:
{topic} best practices {year}{topic} common pitfalls and known issues{topic} {dimension} patterns and recommendationsWrite findings to research.json with full schema:
findings[]: {finding, detail, confidence, source_url}best_practices[]: {practice, rationale, source}alternatives[]: {option, pros, cons, verdict}pitfalls[]: {issue, mitigation, source}codebase_gaps[]: {gap, current_approach, recommended_approach}sources[]: {title, url, key_takeaway}_metadata: {queries_executed, timestamp}Cross-reference: flag where codebase patterns diverge from research best practices as codebase_gaps.
Single perspective (default): Comprehensive analysis across all dimensions using exploration + research context. Write findings directly to discussion.md Round 1.
Multi-perspective (2-4 perspectives, serial): Analyze each perspective sequentially. For each perspective, write a summary subsection in discussion.md Round 1. Then append a synthesis subsection:
If exploration found > 30 relevant files in exploration-codebase.json:
exploration-codebase.json with trimmed list + _budget{original_count, summarized_count}Append to Discussion Timeline using [Round Template](#round-template):
Extract original user intents from discussion.md header. Check each against Round 1 findings:
Append to discussion.md: "接下来的讨论将重点关注未覆盖 (❌) 和进行中 (🔄) 的意图。"
Score each dimension on 5 weighted factors (each [0.0, 1.0]):
| Factor | Weight | Measures |
|--------|--------|----------|
| findings_depth | 0.30 | How deep the findings go |
| evidence_strength | 0.25 | Hard evidence vs inference |
| coverage_breadth | 0.20 | How much of the dimension is covered |
| user_validation | 0.15 | User confirmed findings (starts at 0, increases in Phase 3) |
| consistency | 0.10 | Findings don't contradict |
Overall confidence = weighted average across dimensions. Identify weakest dimension.
Update state.json confidence section. Append confidence table to discussion.md:
#### Confidence Score (Baseline)
| Dimension | Depth | Evidence | Coverage | Validation | Consistency | **Score** |
|-----------|-------|----------|----------|------------|-------------|-----------|
| {dim} | {x} | {x} | {x} | 0.00 | {x} | **{x}** |
Overall: {N}% | Weakest: {dim} ({N}%)
> < 60%: 建议继续深入 | 60-80%: 可选深入或收敛 | > 80%: 建议收敛到结论
Phase 2 exit criteria: exploration-codebase.json created (if codebase), research.json created (if topic warrants), discussion.md updated with Round 1, initial intent coverage check done, baseline confidence computed.
Mark phase-2 completed, phase-3 in_progress.
---
Max 5 rounds. Each round follows this sequence.
Every analysis action in Phase 3 MUST include a summary of ALL prior findings to avoid re-discovering known information:
## KNOWN FINDINGS (DO NOT re-discover)
- Established files: {list from exploration-codebase.json}
- Key findings: {from discussion.md rounds}
- Open questions: {remaining}
## NEW TASK: Focus ONLY on unexplored areas below.
Round ≥ 2 preamble: 1-2 sentence recap of established consensus + last round's direction + confidence delta. Example: "到目前为止,我们已确认 [facts]。上一轮 [direction]。Confidence 从 52% 提升到 67%,security 维度仍需深入。"
Read latest confidence from state.json. Identify weakest dimension.
Present via functions.request_user_input (single question, multiSelect: false, 4 options):
Question header shows: Round {N} | Confidence: {N}% | 最弱: {dim} ({N}%)
Record-Before-Continue Rule: Each path below MUST write findings and discussion synthesis to discussion.md BEFORE proceeding to state update or next round.
Recording Checkpoint (all paths): Record user's original choice, impact on direction, and full Decision Record if direction changed.
Technical Solution Triggers: When an implementation approach is described with specific files/patterns, 2+ alternatives compared, or user confirms/rejects an approach → record using [Technical Solution format](#record-formats).
Ambiguity Check: For each Technical Solution with Status "Proposed", verify no unresolved alternatives remain. If 2+ options without a chosen one → flag:
> **⚠️ Ambiguity**: [Solution] has [N] unresolved alternatives: [list]
> - **Needs**: [Decision criteria or exploration to resolve]
Surface to user in next feedback round.
Ask sub-question via functions.request_user_input (multiSelect: false, max 4 total):
Execute inline search using Grep/Glob/Read/mcp__ace-tool__search_context. Merge new findings with prior context. Record confirmed assumptions and exploration angles.
Ask research topic via functions.request_user_input (max 4 options):
Execute web.run({search_query: "{topic} best practices {year}"}). Merge findings into research.json (append, don't overwrite). Record as Key Findings in discussion.md. Cross-reference with codebase; flag new codebase_gaps.
Ask new focus. Analyze from adjusted perspective. Compare new insights with prior analysis. Record as Decision: trigger, old→new direction, expected impact.
Trigger [Pre-Synthesis Readiness Gate](#35-pre-synthesis-readiness-gate). If passed → exit to Phase 4. If blocked → user chooses to address gaps or accept risk (residual risks recorded in state.json + discussion.md).
Record why concluding at this round.
Append to Discussion Timeline using [Round Template](#round-template): User Input, Decision Log, Key Findings, Technical Solutions, Analysis Results, Corrected Assumptions, Open Items, Confidence Score, Narrative Synthesis.
Overwrite (not append) ## Current Understanding with latest consolidated state following [Consolidation Rules](#consolidation-rules).
Update ## Table of Contents with new Round N links.
Execute after documenting each round.
When quality.pressure_pass_done is false and current round has key findings:
Select the highest-confidence finding and apply the pressure ladder in sequence:
Stay on the same finding until validated or corrected — don't rotate for coverage. A finding that survives is promoted to high-confidence; one that doesn't is flagged.
Record in discussion.md:
#### Pressure Pass (Round N)
> **Target**: [finding]
> - **Confidence claimed**: [level] | **Evidence**: [assessment]
> - **Hidden assumption**: [identified]
> - **Boundary impact**: [tradeoff or scope consequence]
> - **Verdict**: [Confirmed with evidence / Weakened — needs more data / Corrected]
Set quality.pressure_pass_done = true in state.json.
Each mode fires at most once per session. Track in quality.challenge_modes_used[].
| Mode | Trigger | Challenge |
|------|---------|-----------|
| Devil's Advocate | Round 2+ AND any dimension confidence > 0.7 | "如果 [finding] 不成立,分析结论会如何改变?有什么证据可能推翻它?" |
| Scope Minimizer | Key findings count > 5 AND scope expanding (new dimensions added) | "哪些发现可以合并?最小可行结论集是什么?是否在分析不必要的方面?" |
| Root Cause Probe | User feedback contains causal language ("因为", "导致", "由于") | "这是根因还是症状?上游还有什么因素在起作用?" |
Record in discussion.md:
#### Challenge: {Mode}
> **Target**: [finding or observation]
> **Counter-scenario / Question**: [challenge content]
> **Result**: [survived / weakened / corrected]
After each round, assess: new findings? corrected assumptions? confidence delta > 5%?
If NONE of these for 2 consecutive rounds (quality.stall_counter >= 2):
functions.request_user_input (3 options):Re-compute all dimension scores. user_validation factor increases as user confirms findings across rounds.
Update state.json: confidence.dimensions, `confidence.
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.