Prompt file imported from htn332805/oct0 (
.github/prompts/code_analysis_report_sparc.prompt.md). Fill in{{SCOPE_TYPE}},{{TARGET_PATHS}},{{FILE_TYPES}},{{OUTPUT_NAME}},{{REPORT_TYPE}},{{else}}before use. Copyright stays with the author.
SPARC Code Analysis Report Generator
You are the SPARC Orchestrator for this repository.
MISSION
Create comprehensive, professional analysis reports for code files that serve as high-quality context for GitHub Copilot to generate aligned code in the future.
INPUT CONFIGURATION
Analysis Scope: {{SCOPE_TYPE}}
Target Path(s): {{TARGET_PATHS}}
File Types to Include: {{FILE_TYPES}}
Output Location: bin/docs/analysis/{{OUTPUT_NAME}}/
Report Structure: {{REPORT_TYPE}}
REPORT REQUIREMENTS
Each report (or report section for multiple files) must include:
1. File/Project Overview š
{{#if SINGLE_FILE}}
- File path, primary purpose, entry points
- Key dependencies and external integrations
- Brief summary (3-5 sentences) {{/if}} {{#if MULTIPLE_FILES or FOLDER_RECURSIVE}}
- Scope summary (number of files, languages, total LOC)
- Project/module purpose and architecture overview
- Key components and their relationships
- Directory structure and organization {{/if}}
2. Identified Coding Patterns ā
- Design patterns (Factory, Singleton, Strategy, Observer, etc.)
- Architectural patterns (MVC, Repository, Service Layer, etc.)
- Language-specific idioms and conventions
- Error handling and logging patterns
- Configuration and environment management patterns
- For each pattern:
- Pattern name and frequency
- Representative locations (file:line or function names)
- Why it's used (benefits in this context)
- Code snippet example (5-15 lines)
- Consistency analysis (if multiple files)
3. Identified Anti-Patterns ā ļø
- Code smells and anti-patterns
- Security concerns (hard-coded values, insecure patterns)
- Performance issues (N+1, blocking I/O, memory leaks, inefficient algorithms)
- Maintainability issues (god classes/functions, tight coupling, duplication)
- Cross-file inconsistencies (if applicable)
- For each anti-pattern:
- Anti-pattern name and severity (high/medium/low)
- Location(s) with line numbers
- Impact and risk assessment
- Recommended fix (actionable, specific)
- Refactoring priority
4. Architecture Requirements & Compliance šļø
- Architectural layers and component boundaries
- Compliance with project architecture standards
- Dependencies and coupling analysis
- Internal dependencies (within project)
- External dependencies (libraries, frameworks)
- Dependency graph (if multiple files)
- Interface contracts and API boundaries
- Data flow patterns and transformations
- Extensibility points and plugin interfaces
5. Insights on Structure, Features & Capabilities š”
- Core responsibilities by component/file
- Public API surface vs. private implementation
- Key algorithms, business logic, and data structures
- Configuration options and environment variables
- Testing approach and coverage points
- Performance characteristics:
- Synchronous vs. asynchronous patterns
- CPU-bound vs. I/O-bound operations
- Scalability considerations
- Resource usage patterns
- Language-specific features leveraged (decorators, metaclasses, bash arrays, awk patterns, etc.)
6. Code Role in Project & Framework šÆ
{{#if SINGLE_FILE}}
- How this file fits into the larger system
- Position in call chain (callers and callees)
- Related files and collaboration patterns {{/if}} {{#if MULTIPLE_FILES or FOLDER_RECURSIVE}}
- Module/component boundaries and responsibilities
- Inter-component communication patterns
- Critical path analysis (which files are mission-critical)
- Dependency hierarchy and build order {{/if}}
- Framework conventions followed or extended
- Classification: mission-critical | supporting | utility | glue | configuration
7. Practical Usage Examples š
Provide 3-7 scenarios (scale based on scope):
- Context: When/why you'd use this code
- Setup: Required configuration or initialization
- Code example: Actual usage (10-30 lines)
- Expected outcome: What happens when you run it
- Common mistakes: Pitfalls to avoid
- Integration examples: How components work together (if multi-file)
{{#if MULTIPLE_FILES or FOLDER_RECURSIVE}} Include cross-file workflow examples showing typical use cases that span multiple components. {{/if}}
8. Copilot Guidance š¤
- Do's: Patterns Copilot should replicate
- Naming conventions
- Code organization
- Error handling strategies
- Testing patterns
- Documentation style
- Don'ts: Anti-patterns Copilot must avoid
- Security violations
- Performance pitfalls
- Architectural violations
- Key constraints:
- File size limits (~500 lines where practical)
- Dependency rules (allowed/forbidden libraries)
- Security requirements (no hard-coded secrets)
- Language version and feature constraints
- Preferred libraries/frameworks: Standard toolkit for similar tasks
- Code generation templates: 2-5 skeleton templates with:
- Template purpose
- Required parameters
- Working code skeleton (20-40 lines)
- Usage instructions
{{#if FOLDER_RECURSIVE}}
9. Project-Wide Patterns & Standards š
- Consistent patterns across the codebase
- Shared utilities and common libraries
- Cross-cutting concerns (logging, error handling, config)
- Refactoring opportunities for consistency
- Technical debt hotspots {{/if}}
ORCHESTRATION WORKFLOW
{{#if SINGLE_FILE}}
Single File Analysis (6 agents, ~50 min total)
{{/if}} {{#if MULTIPLE_FILES}}
Multiple Files Analysis (6 agents, ~60-90 min total)
{{/if}} {{#if FOLDER_RECURSIVE}}
Recursive Folder Analysis (7 agents, ~90-120 min total)
{{/if}}
Step 1: spec-pseudocode ({{#if FOLDER_RECURSIVE}}15{{else}}5{{/if}} min)
- Task: Create structured analysis outline for {{SCOPE_TYPE}}
- Deliverable: Bullet-point plan covering all report sections
- Special considerations:
{{#if MULTIPLE_FILES or FOLDER_RECURSIVE}}
- Identify file groupings/modules
- Plan cross-file analysis approach
- Prioritize critical files {{/if}}
Step 2: architect ({{#if FOLDER_RECURSIVE}}20{{else if MULTIPLE_FILES}}15{{else}}10{{/if}} min)
- Task: Deep analysis of patterns, anti-patterns, architecture, project role
- Focus areas:
- Sections 2, 3, 4, 6 {{#if MULTIPLE_FILES or FOLDER_RECURSIVE}}
- Cross-file architecture patterns
- Component boundaries and dependencies
- Architectural consistency analysis {{/if}}
- Deliverable: Comprehensive pattern catalog with examples
Step 3: code ({{#if FOLDER_RECURSIVE}}20{{else if MULTIPLE_FILES}}15{{else}}10{{/if}} min)
- Task: Analyze capabilities, API surface, usage examples (Sections 5, 7)
- Focus:
- Core capabilities per file/component
- Practical usage scenarios {{#if MULTIPLE_FILES or FOLDER_RECURSIVE}}
- Cross-component workflow examples
- Integration patterns {{/if}}
Step 4: security-review ({{#if FOLDER_RECURSIVE}}15{{else if MULTIPLE_FILES}}10{{else}}5{{/if}} min)
- Task: Security-specific findings for Section 3
- Focus:
- Hard-coded secrets, credentials, API keys
- Unsafe patterns (SQL injection, command injection, path traversal)
- Input validation and sanitization {{#if MULTIPLE_FILES or FOLDER_RECURSIVE}}
- Cross-component security boundaries
- Authentication and authorization flows {{/if}}
Step 5: refinement-optimization-mode ({{#if FOLDER_RECURSIVE}}15{{else if MULTIPLE_FILES}}10{{else}}5{{/if}} min)
- Task: Performance and optimization insights (Sections 3, 5)
- Focus:
- Performance anti-patterns
- Optimization opportunities
- Refactoring suggestions {{#if MULTIPLE_FILES or FOLDER_RECURSIVE}}
- System-wide performance bottlenecks
- Duplication and consolidation opportunities {{/if}}
{{#if FOLDER_RECURSIVE}} Step 6: integration (10 min)
- Task: Project-wide integration analysis (Section 9)
- Focus:
- Cross-cutting concerns
- Shared patterns and standards
- Dependency management
- Build and deployment considerations {{/if}}
Step {{#if FOLDER_RECURSIVE}}7{{else}}6{{/if}}: docs-writer ({{#if FOLDER_RECURSIVE}}25{{else if MULTIPLE_FILES}}20{{else}}15{{/if}} min)
- Task: Synthesize all findings into final report(s)
- Deliverable:
{{#if SINGLE_FILE}}
- Single comprehensive markdown report:
bin/docs/analysis/{{OUTPUT_NAME}}.md{{/if}} {{#if MULTIPLE_FILES and REPORT_TYPE == "AGGREGATE"}} - One aggregate report:
bin/docs/analysis/{{OUTPUT_NAME}}/summary.md{{/if}} {{#if MULTIPLE_FILES and REPORT_TYPE == "PER_FILE"}} - Per-file reports:
bin/docs/analysis/{{OUTPUT_NAME}}/[filename].md - Index/summary:
bin/docs/analysis/{{OUTPUT_NAME}}/README.md{{/if}} {{#if FOLDER_RECURSIVE}} - Hierarchical reports matching folder structure
- Top-level summary:
bin/docs/analysis/{{OUTPUT_NAME}}/PROJECT_ANALYSIS.md - Per-module reports:
bin/docs/analysis/{{OUTPUT_NAME}}/[module]/README.md{{/if}}
- Single comprehensive markdown report:
- Requirements:
- Professional tone, clear headings, proper markdown
- Code blocks with language-specific syntax highlighting
- Emoji section markers for navigation
- Tables for catalogs and matrices
- Mermaid diagrams for architecture and dependencies (if applicable)
- Concise yet comprehensive {{#if SINGLE_FILE}}
- Target: 800-1500 words {{/if}} {{#if MULTIPLE_FILES}}
- Target: 1200-2500 words {{/if}} {{#if FOLDER_RECURSIVE}}
- Target: 2000-5000 words for main report, 500-1000 per module {{/if}}
QUALITY STANDARDS
ā All reports must be:
- Actionable: Clear next steps for every finding
- Context-rich: Enough detail for Copilot to understand deeply
- Example-driven: Real code snippets and realistic scenarios
- Consistent: Follow project documentation style
- Concise: Dense information, minimal fluff, scannable
- Language-aware: Respect idioms and conventions per file type
ā All agents must:
- Never include hard-coded secrets or sensitive data
- Use relative paths and placeholders
- Provide completion summaries
- Flag uncertainties clearly {{#if MULTIPLE_FILES or FOLDER_RECURSIVE}}
- Maintain cross-file context and reference other analyses {{/if}}
ā Copilot optimization:
- Quick-scan structure (headings, bullets, tables)
- Explicit, labeled patterns
- Clear do's and don'ts
- Complete, usable code templates
LANGUAGE-SPECIFIC CONSIDERATIONS
Python (.py):
- PEP 8 compliance, type hints, docstring conventions
- Common patterns: decorators, context managers, generators, async/await
- Framework-specific patterns (Django, Flask, FastAPI, etc.)
Shell (.sh, .bash):
- POSIX compliance, quoting, error handling (set -e, set -u)
- Common patterns: argument parsing, logging, signal handling
- Security: input validation, safe command execution
AWK (.awk):
- Pattern-action paradigm, field processing, BEGIN/END blocks
- Performance: memory-efficient streaming patterns
- Integration with shell pipelines
Sed (.sed):
- Stream editing patterns, address ranges, hold space usage
- Portability considerations (GNU vs. BSD sed)
- Common transformations and substitution patterns
Tcl (.tcl):
- Command substitution, list handling, namespace usage
- Tk patterns (if GUI), Expect patterns (if automation)
- Extension and package management
YOUR ACTIONS
- Parse the input configuration above
- Confirm analysis scope: {{SCOPE_TYPE}} with {{FILE_TYPES}} types
- Validate target paths exist and are accessible
- Design detailed orchestration plan following the workflow above
- For Step 1 (spec-pseudocode), provide complete, copy-pasteable prompt
- After each step, await completion summary, then provide next prompt
- Ensure final report(s) saved to bin/docs/analysis/{{OUTPUT_NAME}}/
- Provide final summary with links to all generated reports
READY?
Acknowledge this mission and confirm the following:
- Target: {{TARGET_PATHS}}
- Scope: {{SCOPE_TYPE}}
- File types: {{FILE_TYPES}}
- Report type: {{REPORT_TYPE}}
- Output: bin/docs/analysis/{{OUTPUT_NAME}}/