vcnoc/deep-gemini
Deep technical documentation generation workflow using zen mcp's clink and docgen tools. First uses clink to launch gemini CLI in WSL for code analysis, then uses docgen for structured document generation with complexity analysis. Specializes in documents requiring deep understanding of code logic, model architecture, or performance bottleneck analysis. Use when user requests "use gemini for deep analysis", "generate architecture analysis document", "analyze performance bottlenecks", "deeply understand code logic", or similar deep analysis tasks. Default output is .md format.
npx skills add https://github.com/VCnoC/Claude-Code-Zen-mcp-Skill-Work --skill deep-gemini
This skill provides a two-stage deep analysis and documentation workflow:
Stage 1 - Analysis (clink): Launch gemini CLI in WSL to perform deep code/architecture/performance analysis
Stage 2 - Documentation (docgen): Generate structured technical documents with Big O complexity analysis
All operations leverage zen-mcp's workflow tools to ensure thorough analysis and professional documentation output.
Technical Architecture:
gemini command in WSL, where deep analysis is executedTwo-Stage Workflow:
Main Claude → clink → Gemini CLI (Analysis) → docgen → Structured Doc → User
↑ ↓
└──────────────────── User Approval ──────────────────────────────┘
Division of Responsibilities:
Stage 1 (Analysis via clink):
Stage 2 (Documentation via docgen):
Trigger this skill when the user requests:
Distinction from simple-gemini:
This skill specializes in generating the following types of deep analysis documents:
Output Format:
.md (Markdown)Key Feature - Complexity Analysis:
All generated documents include Big O complexity analysis where applicable, providing developers with clear performance characteristics of analyzed code.
automation_mode definition and constraints: See CLAUDE.md「📚 共享概念速查」
This skill's role: Skill Layer (read-only), read from context [AUTOMATION_MODE: true/false]
false → Interactive: Show document, ask for approvaltrue → Automated: Auto-save document, log to auto_log.mdMain Claude's Responsibilities:
Analysis Target: [Specify analysis object]
Analysis Type: [Code Logic/Architecture/Performance/Security]
Key Questions: [Core questions to answer]
Analysis Depth: [Surface/Medium/Deep]
Complexity Analysis: [Yes/No]
Relevant Files: [List all relevant file paths]
Output: Well-defined analysis scope and all necessary context files
Main Claude's Action:
Invoke gemini CLI session via clink for deep analysis:
Tool: mcp__zen__clink
Parameters:
- cli_name: "gemini"
- prompt: "Please perform deep analysis on the following code/architecture/performance data:
Analysis Target: [from Phase 1]
Analysis Type: [from Phase 1]
Key Questions: [from Phase 1]
Please perform the following analysis:
1. [Specific analysis dimension 1]
2. [Specific analysis dimension 2]
3. [Specific analysis dimension 3]
4. Algorithm complexity assessment (time complexity, space complexity, using Big O notation)
Provide detailed analysis results, including:
- Core findings
- Key insights
- Complexity analysis (Big O)
- Potential issues
- Improvement recommendations"
- files: [Absolute paths of all relevant files]
- role: "default"
- continuation_id: [Not provided for first call]
What Happens (clink bridges to Gemini CLI):
gemini command)Gemini CLI's Work (inside WSL session):
Output: Comprehensive analysis findings with complexity data from gemini CLI
Main Claude's Action:
Invoke docgen tool to generate structured document based on analysis results.
Step 1: Exploration Phase
Tool: mcp__zen__docgen
Parameters:
step: |
Explore the analysis project and create a document generation plan based on the following deep analysis results:
Analysis Results:
[Gemini CLI analysis results obtained from Phase 2]
Document Requirements:
1. Include executive summary
2. Detailed methodology description
3. Core findings (hierarchical, multi-dimensional)
4. **Algorithm complexity analysis section** (Big O notation, including time and space complexity)
5. Detailed analysis (in-depth explanation of each finding)
6. Improvement recommendations (priority-sorted)
7. Conclusion and next steps
Format Requirements:
- Markdown format
- Use Mermaid diagrams (architecture diagrams, flowcharts, sequence diagrams)
- Code examples with syntax highlighting
- Complexity analysis presented in tables
step_number: 1
total_steps: 2
next_step_required: true
findings: ""
num_files_documented: 0
document_complexity: "medium"
Step 2+: Per-File Documentation Phase
Tool: mcp__zen__docgen
Parameters:
step: |
Generate structured document for analysis results, including:
- Executive summary
- Complexity analysis (Big O notation)
- Mermaid diagrams
- Code examples
- Improvement recommendations
step_number: 2
total_steps: 2
next_step_required: false
findings: |
[Step 1 exploration results + Gemini CLI analysis results]
num_files_documented: 0
document_complexity: "medium"
continuation_id: [Inherited from Step 1]
What Happens (docgen workflow execution):
Step 1 (Exploration):
Step 2+ (Per-File Documentation):
docgen's Specialized Capabilities:
Output: Complete structured technical document with complexity analysis
Main Claude's Action:
[AUTOMATION_MODE: false] → Interactive (show + ask) / true → Automated (show + auto-save)A) Interactive Mode (automation_mode = false):
Deep analysis document has been generated:
[Display document content summary]
Stats: [N] words, [N] sections, [N] diagrams, [N] examples, [N] complexity analyses
Findings: [Core finding 1], [Core finding 2], [Core finding 3]
Complexity: Highest O(?), Bottleneck: [Description]
Do you need adjustments or additions?
- Satisfied: Save document
- Need modifications: Please specify modification requirements
B) Automated Mode (automation_mode = true):
[Fully Automated Mode] Deep analysis document has been generated and automatically saved:
[Display document content summary]
Stats: [N] words, [N] sections, [N] diagrams, [N] examples, [N] complexity analyses
Findings: [Core finding 1], [Core finding 2], [Core finding 3]
Complexity: Highest O(?), Bottleneck: [Description]
[Automated Save Decision Record]
Decision: Document quality meets standards, automatically saved
Confidence: high
Standards basis: Contains all required sections (executive summary, complexity analysis, mermaid diagrams, recommendations)
Save path: docs/analysis/[analysis_type]_analysis_[timestamp].md
Recorded in auto_log.md
For Analysis Revision (use clink):
Tool: mcp__zen__clink
Parameters:
- cli_name: "gemini"
- prompt: "Please re-analyze the following aspects:
[User's modification requirements]
Please provide updated analysis results."
- continuation_id: [Inherited from Phase 2]
For Document Revision (use docgen):
Tool: mcp__zen__docgen
Parameters:
step: |
Please make the following modifications to the document:
[User's modification requirements]
Please provide the revised complete document.
step_number: 3 # Continue workflow
total_steps: 3
next_step_required: false
findings: |
[Previously generated document content + user modification requirements]
num_files_documented: 1 # Main document completed
document_complexity: "medium"
continuation_id: [Inherited from Phase 3]
{analysis_type}_analysis_{timestamp}.mdOutput: Final document saved to file system
Main Claude's Action (if requested by user):
Purpose: Bridge Zen MCP requests to Gemini CLI in WSL for code analysis
Key Parameters:
cli_name: "gemini" # Launches 'gemini' command in WSL
prompt: | # Analysis task for gemini CLI session
[Detailed analysis instructions including complexity analysis requirements]
files: # Absolute paths to context files
- /absolute/path/to/file1.py
- /absolute/path/to/file2.py
role: "default" # Role preset for gemini CLI
continuation_id: # Session ID to continue previous gemini CLI session
Responsibilities:
Purpose: Multi-step structured document generation with complexity analysis
Key Parameters (Workflow Required):
# Required Parameters (Workflow Fields)
step: | # Description and requirements of the current step
[Detailed instructions for document generation]
[Must include complexity analysis requirements]
step_number: 1 # Current step number
total_steps: 2 # Estimated total steps
next_step_required: true # Whether next step is required
findings: | # Accumulated findings and information
[Previous findings + Analysis results]
# Required Parameters (docgen-specific)
num_files_documented: 0 # Number of files documented
document_complexity: "medium" # Document complexity (low/medium/high)
# Optional Parameters
continuation_id: # Continuation session ID
# Unsupported Parameters (will be rejected)
# prompt - Not accepted
# files - Not accepted
# model - Explicitly excluded
# temperature - Explicitly excluded
# thinking_mode - Explicitly excluded
# images - Explicitly excluded
# working_directory - Does not exist
Specialized Capabilities:
Output:
Phase 1: Main Claude gathers context
↓
Phase 2: clink → Gemini CLI (analysis + complexity evaluation)
↓ [analysis results with complexity data]
Phase 3: docgen (dual-phase workflow)
Step 1: Exploration
- Evaluate project structure
- Create documentation plan
→ Returns continuation_id
Step 2: Per-File Documentation
- Generate structured document
- Include Big O complexity analysis
- Generate Mermaid diagrams
→ Returns complete document
↓ [complete document]
Phase 4: Main Claude → User (review)
↓ [approval or revision request]
Phase 5: Save document (Main Claude)
Must Include:
Complexity Analysis Format:
Use tables for clarity:
## Algorithm Complexity Analysis
| Function/Algorithm | Time Complexity | Space Complexity | Description |
|-------------------|----------------|------------------|-------------|
| train_model() | O(n²) | O(n) | Nested loops cause quadratic complexity |
| predict() | O(n log n) | O(1) | Sorting operations dominate |
| preprocess() | O(n) | O(n) | Linear scan, additional storage |
Mermaid Diagram Types:
flowchart TD/LR: Control flow, decision trees, complexity pathssequenceDiagram: Interaction patterns, call sequencesclassDiagram: Class relationships, inheritancegraph TD/LR: Dependency graphs, component relationshipsFormatting:
User: "Use gemini to deeply analyze the training logic in src/model_training.py, including complexity analysis"
Main Claude:
Okay, I will use gemini to perform deep analysis on the training logic, including algorithm complexity assessment.
[Phase 1: Gathering Context]
Reading src/model_training.py and related dependencies...
[Phase 2: Using clink to invoke Gemini CLI for analysis]
Performing deep analysis...
- Control flow analysis
- Data flow tracing
- Algorithm complexity calculation
- Bottleneck identification
[Phase 3: Using docgen to generate structured document]
Generating complete document with complexity analysis...
[Phase 4: Presenting Results]
Reading context: [AUTOMATION_MODE: false]
Deep analysis document has been generated!
Document Statistics:
- Word count: 4,200
- Section count: 7
- Mermaid diagrams: 4
- Code examples: 10
- Complexity analysis: 8 functions
Key Findings:
- Training loop has O(n²) complexity (nested iteration)
- Data preprocessing can be optimized to O(n log n)
- Memory usage peak occurs during batch processing stage
Complexity Summary:
| Function | Time Complexity | Space Complexity | Optimization Potential |
|----------|----------------|------------------|----------------------|
| train_epoch() | O(n²) | O(n) | High - Can reduce to O(n log n) |
| validate() | O(n) | O(1) | Low |
| save_checkpoint() | O(n) | O(n) | Medium |
Saved to: docs/analysis/model_training_analysis_20251021.md
[Interactive Mode] Do you need further optimization recommendations?
User: "Analyze performance bottlenecks and generate a report, profiling data is in logs/profile.txt, need complexity analysis"
Main Claude:
Okay, I will analyze performance bottlenecks and assess complexity.
[Phase 1: Gathering Context]
- Profiling data: logs/profile.txt
- Hotspot code: [Auto-identified source files]
[Phase 2: clink → Gemini CLI Analysis]
Analyzing profiling data and corresponding code...
- Identifying hotspot functions
- Calculating theoretical complexity
- Comparing with actual performance
[Phase 3: docgen Generating Structured Report]
Generating performance analysis report (with complexity assessment)...
[Phase 4: Result Presentation]
Performance bottleneck analysis report is complete!
Top 3 Bottlenecks:
1. data_loader.load_batch() - O(n²) actual, should be O(n)
→ Root cause: Repeated file reads
→ Expected improvement after optimization: 10x performance gain
2. feature_extractor.transform() - O(n log n) already optimized
→ No significant optimization potential
3. model.predict_batch() - O(n) theoretical, actually O(n²)
→ Root cause: Implicit nested loops
→ Expected improvement after optimization: 5x performance gain
Saved to: docs/analysis/performance_bottleneck_20251021.md
User: "Use gemini to generate an architecture analysis document for the entire data processing flow, assess design complexity"
Main Claude:
I will generate an architecture analysis document for the data processing flow, including complexity assessment.
[Phase 1: Defining Scope]
- Data processing related modules: [List modules]
- Analysis focus: Component interaction, data flow, design complexity
[Phase 2: clink → Gemini CLI Architecture Analysis]
Executing architecture-level analysis...
- Component dependencies
- Data flow path complexity
- Interaction pattern assessment
[Phase 3: docgen Generating Architecture Document]
Generating structured architecture document...
[Phase 4: Results]
Architecture analysis document has been generated!
Architecture Complexity Assessment:
- Component coupling: Medium (6/10)
- Data flow complexity: O(n) - Linear pipeline
- Deepest call stack: 5 levels
- Circular dependencies: 0 (Good)
Key Architecture Findings:
- Pipeline pattern adopted, complexity well controlled
- Suggest introducing cache layer to reduce I/O complexity
- Asynchronous processing can improve throughput by 3x
Document Contains:
- High-level architecture diagram (Mermaid)
- Data flow diagram (Mermaid)
- Sequence diagram (Mermaid)
- Complexity analysis table
- Optimization recommendation roadmap
Saved to: docs/analysis/architecture_analysis_20251021.md
Pre-Analysis Phase:
During Analysis Phase (clink):
During Documentation Phase (docgen):
Post-Documentation Phase:
What Main Claude Does NOT Do:
Bridging Function:
gemini command)Does NOT:
Document Generation Workflow:
Specialized Capabilities:
Does NOT:
Inside the gemini CLI environment in WSL:
Does NOT:
Provide:
Review and Approve:
Optional:
[Automated Save Decision Record] fragments when automation_mode=trueskills/shared/auto_log_template.mdTake vcnoc/deep-gemini from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.