Files
Claude-Code-Workflow/.claude/commands/cli/mode/document-analysis.md
Claude 837bee79c7 feat: add document analysis template for technical documents and papers
Add new CLI mode for systematic technical document analysis with:
- CLI command: /cli:mode:document-analysis for Gemini/Qwen/Codex
- Comprehensive analysis template with 6-phase protocol
- Support for README, API docs, research papers, specifications, tutorials
- Evidence-based analysis with pre-planning and self-critique requirements
- Precise language constraints and structured output format

Template features:
- Pre-analysis planning phase for approach definition
- Multi-phase analysis: assessment, extraction, critical analysis, synthesis
- Self-critique requirement before final output
- Mandatory section references and evidence citations
- Output length control proportional to document size
2025-11-20 10:05:09 +00:00

5.0 KiB

name, description, argument-hint, allowed-tools
name description argument-hint allowed-tools
document-analysis Read-only technical document/paper analysis using Gemini/Qwen/Codex with systematic comprehension template for insights extraction [--tool codex|gemini|qwen] [--enhance] [--cd path] document path or topic SlashCommand(*), Bash(*), Task(*), Read(*)

CLI Mode: Document Analysis (/cli:mode:document-analysis)

Purpose

Systematic analysis of technical documents, research papers, API documentation, and technical specifications.

Tool Selection:

  • gemini (default) - Best for document comprehension and structure analysis
  • qwen - Fallback when Gemini unavailable
  • codex - Alternative for complex technical documents

Key Feature: --cd flag for directory-scoped document discovery

Parameters

  • --tool <gemini|qwen|codex> - Tool selection (default: gemini)
  • --enhance - Enhance analysis target with /enhance-prompt
  • --cd "path" - Target directory for document search
  • <document-path-or-topic> (Required) - File path or topic description

Tool Usage

Gemini (Primary):

/cli:mode:document-analysis "README.md"
/cli:mode:document-analysis --tool gemini "analyze API documentation"

Qwen (Fallback):

/cli:mode:document-analysis --tool qwen "docs/architecture.md"

Codex (Alternative):

/cli:mode:document-analysis --tool codex "research paper in docs/"

Execution Flow

Uses cli-execution-agent for automated document analysis:

Task(
  subagent_type="cli-execution-agent",
  description="Systematic document comprehension and insights extraction",
  prompt=`
    Task: ${document_path_or_topic}
    Mode: document-analysis
    Tool: ${tool_flag || 'gemini'}
    Directory: ${cd_path || '.'}
    Enhance: ${enhance_flag}
    Template: ~/.claude/workflows/cli-templates/prompts/analysis/02-analyze-technical-document.txt

    Execute systematic document analysis:

    1. Document Discovery:
       - Locate target document(s) via path or topic keywords
       - Identify document type (README, API docs, research paper, spec, tutorial)
       - Detect document format (Markdown, PDF, plain text, reStructuredText)
       - Discover related documents (references, appendices, examples)
       - Use MCP/ripgrep for comprehensive file discovery

    2. Pre-Analysis Planning (Required):
       - Determine document structure (sections, hierarchy, flow)
       - Identify key components (abstract, methodology, implementation details)
       - Map dependencies and cross-references
       - Assess document scope and complexity
       - Plan analysis approach based on document type

    3. CLI Command Construction:
       - Tool: ${tool_flag || 'gemini'} (qwen fallback, codex for complex docs)
       - Directory: cd ${cd_path || '.'} &&
       - Context: @{document_paths} + @CLAUDE.md + related files
       - Mode: analysis (read-only)
       - Template: analysis/02-analyze-technical-document.txt

    4. Analysis Execution:
       - Apply 6-field template structure (PURPOSE, TASK, MODE, CONTEXT, EXPECTED, RULES)
       - Execute multi-phase analysis protocol with pre-planning
       - Perform self-critique before final output
       - Generate structured report with evidence-based insights

    5. Output Generation:
       - Comprehensive document analysis report
       - Structured insights with section references
       - Critical assessment with evidence
       - Actionable recommendations
       - Save to .workflow/active/WFS-[id]/.chat/doc-analysis-[timestamp].md (or .scratchpad/)
  `
)

Core Rules

  • Read-only: Analyzes documents, does NOT modify files
  • Evidence-based: All claims must reference specific sections/pages
  • Pre-planning: Requires analysis approach planning before execution
  • Precise language: Direct, accurate wording - no persuasive embellishment
  • Output: .workflow/active/WFS-[id]/.chat/doc-analysis-[timestamp].md (or .scratchpad/ if no session)

Document Types Supported

Type Focus Areas Key Outputs
README Purpose, setup, usage Integration steps, quick-start guide
API Documentation Endpoints, parameters, responses API usage patterns, integration points
Research Paper Methodology, findings, validity Applicable techniques, implementation feasibility
Specification Requirements, standards, constraints Compliance checklist, implementation requirements
Tutorial Learning path, examples, exercises Key concepts, practical applications
Architecture Docs System design, components, patterns Design decisions, integration points, trade-offs

Best Practices

  1. Scope Definition: Clearly define what aspects to analyze before starting
  2. Layered Reading: Structure/Overview → Details → Critical Analysis → Synthesis
  3. Evidence Trail: Track section references for all extracted information
  4. Gap Identification: Note missing information or unclear sections explicitly
  5. Actionable Output: Focus on insights that inform decisions or actions