mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-14 02:42:04 +08:00
feat: Implement multi-phase project analysis workflow with Mermaid diagram generation and CPCC compliance documentation
- Phase 3: Added Mermaid diagram generation for system architecture, function modules, algorithms, class diagrams, sequence diagrams, and error flows. - Phase 4: Assembled analysis and diagrams into a structured CPCC-compliant document with section templates and figure numbering. - Phase 5: Developed compliance review process with iterative refinement based on analysis findings and user feedback. - Added CPCC compliance requirements and quality standards for project analysis reports. - Established a comprehensive project analysis skill with detailed execution flow and report types. - Enhanced error handling and recovery mechanisms throughout the analysis phases.
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
# Phase 1: Requirements Discovery
|
||||
|
||||
Collect user requirements before analysis begins.
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1: Report Type Selection
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "What type of project analysis report would you like?",
|
||||
header: "Report Type",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{label: "Architecture (Recommended)", description: "System structure, module relationships, layer analysis, dependency graph"},
|
||||
{label: "Design", description: "Design patterns, class relationships, component interactions, abstraction analysis"},
|
||||
{label: "Methods", description: "Key algorithms, critical code paths, core function explanations with examples"},
|
||||
{label: "Comprehensive", description: "All above combined into a complete project analysis"}
|
||||
]
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
### Step 2: Depth Level Selection
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "What depth level do you need?",
|
||||
header: "Depth",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{label: "Overview", description: "High-level understanding, suitable for onboarding"},
|
||||
{label: "Detailed", description: "In-depth analysis with code examples"},
|
||||
{label: "Deep-Dive", description: "Exhaustive analysis with implementation details"}
|
||||
]
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
### Step 3: Scope Definition
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "What scope should the analysis cover?",
|
||||
header: "Scope",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{label: "Full Project", description: "Analyze entire codebase"},
|
||||
{label: "Specific Module", description: "Focus on a specific module or directory"},
|
||||
{label: "Custom Path", description: "Specify custom path pattern"}
|
||||
]
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
## Focus Areas Mapping
|
||||
|
||||
| Report Type | Focus Areas |
|
||||
|-------------|-------------|
|
||||
| Architecture | Layer Structure, Module Dependencies, Entry Points, Data Flow |
|
||||
| Design | Design Patterns, Class Relationships, Interface Contracts, State Management |
|
||||
| Methods | Core Algorithms, Critical Paths, Public APIs, Complex Logic |
|
||||
| Comprehensive | All above combined |
|
||||
|
||||
## Output
|
||||
|
||||
Save configuration to `analysis-config.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "architecture|design|methods|comprehensive",
|
||||
"depth": "overview|detailed|deep-dive",
|
||||
"scope": "**/*|src/**/*|custom",
|
||||
"focus_areas": ["..."]
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,74 @@
|
||||
# Phase 2: Project Exploration
|
||||
|
||||
Launch parallel exploration agents based on report type.
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1: Map Exploration Angles
|
||||
|
||||
```javascript
|
||||
const angleMapping = {
|
||||
architecture: ["Layer Structure", "Module Dependencies", "Entry Points", "Data Flow"],
|
||||
design: ["Design Patterns", "Class Relationships", "Interface Contracts", "State Management"],
|
||||
methods: ["Core Algorithms", "Critical Paths", "Public APIs", "Complex Logic"],
|
||||
comprehensive: ["Layer Structure", "Design Patterns", "Core Algorithms", "Data Flow"]
|
||||
};
|
||||
|
||||
const angles = angleMapping[config.type];
|
||||
```
|
||||
|
||||
### Step 2: Launch Parallel Agents
|
||||
|
||||
For each angle, launch an exploration agent:
|
||||
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-explore-agent",
|
||||
description: `Explore: ${angle}`,
|
||||
prompt: `
|
||||
## Exploration Objective
|
||||
Execute **${angle}** exploration for project analysis report.
|
||||
|
||||
## Context
|
||||
- **Angle**: ${angle}
|
||||
- **Report Type**: ${config.type}
|
||||
- **Depth**: ${config.depth}
|
||||
- **Scope**: ${config.scope}
|
||||
|
||||
## Exploration Protocol
|
||||
1. Structural Discovery (get_modules_by_depth, rg, glob)
|
||||
2. Pattern Recognition (conventions, naming, organization)
|
||||
3. Relationship Mapping (dependencies, integration points)
|
||||
|
||||
## Output Format
|
||||
{
|
||||
"angle": "${angle}",
|
||||
"findings": {
|
||||
"structure": [...],
|
||||
"patterns": [...],
|
||||
"relationships": [...],
|
||||
"key_files": [{path, relevance, rationale}]
|
||||
},
|
||||
"insights": [...]
|
||||
}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
### Step 3: Aggregate Results
|
||||
|
||||
Merge all exploration results into unified findings:
|
||||
|
||||
```javascript
|
||||
const aggregatedFindings = {
|
||||
structure: [], // from all angles
|
||||
patterns: [], // from all angles
|
||||
relationships: [], // from all angles
|
||||
key_files: [], // deduplicated
|
||||
insights: [] // prioritized
|
||||
};
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Save exploration results to `exploration-{angle}.json` files.
|
||||
58
.claude/skills/project-analyze/phases/03-deep-analysis.md
Normal file
58
.claude/skills/project-analyze/phases/03-deep-analysis.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Phase 3: Deep Analysis
|
||||
|
||||
Execute deep analysis using Gemini CLI with exploration context.
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1: Prepare CLI Prompt
|
||||
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Generate ${type} analysis report for project
|
||||
TASK:
|
||||
• Analyze project structure and patterns from ${type} perspective
|
||||
• Focus on: ${focus_areas}
|
||||
• Depth level: ${depth}
|
||||
• Key files: ${key_files}
|
||||
MODE: analysis
|
||||
CONTEXT: @**/* | Exploration results
|
||||
EXPECTED:
|
||||
- Structured analysis
|
||||
- Code references (file:line format)
|
||||
- Mermaid diagram data
|
||||
- Actionable insights
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md)
|
||||
" --tool gemini --mode analysis
|
||||
```
|
||||
|
||||
### Step 2: Parse Analysis Results
|
||||
|
||||
Extract structured data from CLI response:
|
||||
|
||||
```javascript
|
||||
const deepAnalysis = {
|
||||
findings: [], // Analyzed findings with confidence scores
|
||||
patterns: [], // Identified patterns with consistency scores
|
||||
dependencies: [], // Dependency relationships
|
||||
recommendations: [], // Prioritized recommendations
|
||||
sections: [], // Report section data
|
||||
diagram_data: {} // Data for diagram generation
|
||||
};
|
||||
```
|
||||
|
||||
### Step 3: Validate Analysis Quality
|
||||
|
||||
Check analysis completeness:
|
||||
|
||||
```javascript
|
||||
const qualityChecks = {
|
||||
has_executive_summary: Boolean,
|
||||
focus_areas_covered: config.focus_areas.every(area => analysis.covers(area)),
|
||||
code_references_valid: analysis.references.every(ref => fileExists(ref)),
|
||||
insights_actionable: analysis.insights.filter(i => i.actionable).length > 0
|
||||
};
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Save analysis results to `deep-analysis.json`.
|
||||
@@ -0,0 +1,86 @@
|
||||
# Phase 3.5: Diagram Generation
|
||||
|
||||
Generate Mermaid diagrams based on report type and analysis data.
|
||||
|
||||
> **Reference**: See [mermaid-utils.md](../../_shared/mermaid-utils.md) for utility functions.
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1: Determine Required Diagrams
|
||||
|
||||
```javascript
|
||||
const diagramRequirements = {
|
||||
architecture: [
|
||||
{type: 'architecture', format: 'graph TD', file: 'architecture.mmd'},
|
||||
{type: 'layers', format: 'graph TD', file: 'layers.mmd'},
|
||||
{type: 'dependencies', format: 'graph LR', file: 'dependencies.mmd'},
|
||||
{type: 'dataflow', format: 'flowchart LR', file: 'dataflow.mmd'}
|
||||
],
|
||||
design: [
|
||||
{type: 'class', format: 'classDiagram', file: 'class-diagram.mmd'},
|
||||
{type: 'components', format: 'graph TD', file: 'components.mmd'},
|
||||
{type: 'patterns', format: 'graph TD', file: 'patterns.mmd'},
|
||||
{type: 'state', format: 'stateDiagram-v2', file: 'state.mmd'}
|
||||
],
|
||||
methods: [
|
||||
{type: 'algorithm', format: 'flowchart TD', file: 'algorithm-*.mmd'},
|
||||
{type: 'sequence', format: 'sequenceDiagram', file: 'sequence-*.mmd'},
|
||||
{type: 'critical_path', format: 'flowchart LR', file: 'critical-path.mmd'},
|
||||
{type: 'api', format: 'graph LR', file: 'api.mmd'}
|
||||
],
|
||||
comprehensive: [
|
||||
{type: 'architecture', format: 'graph TD', file: 'architecture.mmd'},
|
||||
{type: 'class', format: 'classDiagram', file: 'class-diagram.mmd'},
|
||||
{type: 'sequence', format: 'sequenceDiagram', file: 'sequence-main.mmd'},
|
||||
{type: 'dataflow', format: 'flowchart LR', file: 'dataflow.mmd'}
|
||||
]
|
||||
};
|
||||
|
||||
const required = diagramRequirements[config.type];
|
||||
```
|
||||
|
||||
### Step 2: Generate Each Diagram
|
||||
|
||||
Use shared utilities from `../_shared/mermaid-utils.md`:
|
||||
|
||||
```javascript
|
||||
// Import utilities
|
||||
const { sanitizeId, escapeLabel, generateClassDiagram, generateSequenceDiagram, validateMermaidSyntax } = require('../_shared/mermaid-utils.md');
|
||||
|
||||
for (const diagram of required) {
|
||||
const content = generateDiagram(diagram.type, diagram.format, analysisData);
|
||||
Write(`${outputDir}/diagrams/${diagram.file}`, content);
|
||||
}
|
||||
```
|
||||
|
||||
### Step 3: Validate All Diagrams
|
||||
|
||||
```javascript
|
||||
const validationResults = validateDiagramDirectory(`${outputDir}/diagrams`);
|
||||
const failedDiagrams = validationResults.filter(r => !r.valid);
|
||||
|
||||
if (failedDiagrams.length > 0) {
|
||||
// Regenerate failed diagrams
|
||||
for (const failed of failedDiagrams) {
|
||||
regenerateDiagram(failed.file, failed.issues);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Step 4: Create Diagram Manifest
|
||||
|
||||
```javascript
|
||||
Write(`${outputDir}/diagrams/manifest.json`, JSON.stringify({
|
||||
generated_at: new Date().toISOString(),
|
||||
diagrams: required.map(d => ({
|
||||
type: d.type,
|
||||
file: d.file,
|
||||
format: d.format
|
||||
})),
|
||||
validation: validationResults
|
||||
}, null, 2));
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Save diagrams to `diagrams/` folder with `manifest.json`.
|
||||
@@ -0,0 +1,94 @@
|
||||
# Phase 4: Report Generation
|
||||
|
||||
Assemble analysis and diagrams into structured Markdown report.
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1: Determine Report Sections
|
||||
|
||||
```javascript
|
||||
const reportSections = {
|
||||
architecture: [
|
||||
"# Architecture Report",
|
||||
"## Executive Summary",
|
||||
"## System Overview",
|
||||
"## Layer Analysis",
|
||||
"## Module Dependencies",
|
||||
"## Data Flow",
|
||||
"## Entry Points & Critical Paths",
|
||||
"## Dependency Graph",
|
||||
"## Recommendations"
|
||||
],
|
||||
design: [
|
||||
"# Design Report",
|
||||
"## Executive Summary",
|
||||
"## Design Patterns Used",
|
||||
"## Class Relationships",
|
||||
"## Interface Contracts",
|
||||
"## State Management",
|
||||
"## Component Diagrams",
|
||||
"## Design Recommendations"
|
||||
],
|
||||
methods: [
|
||||
"# Key Methods Report",
|
||||
"## Executive Summary",
|
||||
"## Core Algorithms",
|
||||
"## Critical Code Paths",
|
||||
"## Public API Reference",
|
||||
"## Complex Logic Breakdown",
|
||||
"## Sequence Diagrams",
|
||||
"## Optimization Suggestions"
|
||||
],
|
||||
comprehensive: [
|
||||
"# Comprehensive Project Analysis",
|
||||
"## Executive Summary",
|
||||
"## Architecture Overview",
|
||||
"## Design Patterns & Principles",
|
||||
"## Key Methods & Algorithms",
|
||||
"## System Diagrams",
|
||||
"## Recommendations & Next Steps"
|
||||
]
|
||||
};
|
||||
|
||||
const sections = reportSections[config.type];
|
||||
```
|
||||
|
||||
### Step 2: Generate Report Content
|
||||
|
||||
```javascript
|
||||
let report = '';
|
||||
|
||||
for (const section of sections) {
|
||||
report += section + '\n\n';
|
||||
|
||||
// Add section content from analysis
|
||||
const sectionContent = generateSectionContent(section, deepAnalysis);
|
||||
report += sectionContent + '\n\n';
|
||||
|
||||
// Embed relevant diagrams
|
||||
const relatedDiagrams = findRelatedDiagrams(section, diagrams);
|
||||
for (const diagram of relatedDiagrams) {
|
||||
report += `\`\`\`mermaid\n${Read(diagram.path)}\n\`\`\`\n\n`;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Step 3: Add Code References
|
||||
|
||||
Format all code references as `file:line`:
|
||||
|
||||
```javascript
|
||||
// Example: src/auth/login.ts:42
|
||||
const codeRef = `${finding.file}:${finding.line}`;
|
||||
```
|
||||
|
||||
### Step 4: Write Report
|
||||
|
||||
```javascript
|
||||
const reportFileName = `${config.type.toUpperCase()}-REPORT.md`;
|
||||
Write(`${outputDir}/${reportFileName}`, report);
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Generate `{TYPE}-REPORT.md` in output directory.
|
||||
124
.claude/skills/project-analyze/phases/05-iterative-refinement.md
Normal file
124
.claude/skills/project-analyze/phases/05-iterative-refinement.md
Normal file
@@ -0,0 +1,124 @@
|
||||
# Phase 5: Iterative Refinement
|
||||
|
||||
Discovery-driven refinement based on analysis findings.
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1: Extract Discoveries
|
||||
|
||||
```javascript
|
||||
function extractDiscoveries(deepAnalysis) {
|
||||
return {
|
||||
ambiguities: deepAnalysis.findings.filter(f => f.confidence < 0.7),
|
||||
complexityHotspots: deepAnalysis.findings.filter(f => f.complexity === 'high'),
|
||||
patternDeviations: deepAnalysis.patterns.filter(p => p.consistency < 0.8),
|
||||
unclearDependencies: deepAnalysis.dependencies.filter(d => d.type === 'implicit'),
|
||||
potentialIssues: deepAnalysis.recommendations.filter(r => r.priority === 'investigate'),
|
||||
depthOpportunities: deepAnalysis.sections.filter(s => s.has_more_detail)
|
||||
};
|
||||
}
|
||||
|
||||
const discoveries = extractDiscoveries(deepAnalysis);
|
||||
```
|
||||
|
||||
### Step 2: Build Dynamic Questions
|
||||
|
||||
Questions emerge from discoveries, NOT predetermined:
|
||||
|
||||
```javascript
|
||||
function buildDynamicQuestions(discoveries, config) {
|
||||
const questions = [];
|
||||
|
||||
if (discoveries.ambiguities.length > 0) {
|
||||
questions.push({
|
||||
question: `Analysis found ambiguity in "${discoveries.ambiguities[0].area}". Which interpretation is correct?`,
|
||||
header: "Clarify",
|
||||
options: discoveries.ambiguities[0].interpretations
|
||||
});
|
||||
}
|
||||
|
||||
if (discoveries.complexityHotspots.length > 0) {
|
||||
questions.push({
|
||||
question: `These areas have high complexity. Which would you like explained?`,
|
||||
header: "Deep-Dive",
|
||||
multiSelect: true,
|
||||
options: discoveries.complexityHotspots.slice(0, 4).map(h => ({
|
||||
label: h.name,
|
||||
description: h.summary
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
if (discoveries.patternDeviations.length > 0) {
|
||||
questions.push({
|
||||
question: `Found pattern deviations. Should these be highlighted in the report?`,
|
||||
header: "Patterns",
|
||||
options: [
|
||||
{label: "Yes, include analysis", description: "Add section explaining deviations"},
|
||||
{label: "No, skip", description: "Omit from report"}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
// Always include action question
|
||||
questions.push({
|
||||
question: "How would you like to proceed?",
|
||||
header: "Action",
|
||||
options: [
|
||||
{label: "Continue refining", description: "Address more discoveries"},
|
||||
{label: "Finalize report", description: "Generate final output"},
|
||||
{label: "Change scope", description: "Modify analysis scope"}
|
||||
]
|
||||
});
|
||||
|
||||
return questions.slice(0, 4); // Max 4 questions
|
||||
}
|
||||
```
|
||||
|
||||
### Step 3: Apply Refinements
|
||||
|
||||
```javascript
|
||||
if (userAction === "Continue refining") {
|
||||
// Apply selected refinements
|
||||
for (const selection of userSelections) {
|
||||
applyRefinement(selection, deepAnalysis, report);
|
||||
}
|
||||
|
||||
// Save iteration
|
||||
Write(`${outputDir}/iterations/iteration-${iterationCount}.json`, {
|
||||
timestamp: new Date().toISOString(),
|
||||
discoveries: discoveries,
|
||||
selections: userSelections,
|
||||
changes: appliedChanges
|
||||
});
|
||||
|
||||
// Loop back to Step 1
|
||||
iterationCount++;
|
||||
goto Step1;
|
||||
}
|
||||
|
||||
if (userAction === "Finalize report") {
|
||||
// Proceed to final output
|
||||
goto FinalizeReport;
|
||||
}
|
||||
```
|
||||
|
||||
### Step 4: Finalize Report
|
||||
|
||||
```javascript
|
||||
// Add iteration history to report metadata
|
||||
const finalReport = {
|
||||
...report,
|
||||
metadata: {
|
||||
iterations: iterationCount,
|
||||
refinements_applied: allRefinements,
|
||||
final_discoveries: discoveries
|
||||
}
|
||||
};
|
||||
|
||||
Write(`${outputDir}/${config.type.toUpperCase()}-REPORT.md`, finalReport);
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Updated report with refinements, saved iterations to `iterations/` folder.
|
||||
Reference in New Issue
Block a user