cognitives/skills/analytics/code-analyzer/SKILL.md
Analyzes code modules and generates structured technical reports with architecture diagrams. Trigger: When the user asks to analyze, explain, or document a module, file, or codebase section.
npx skillsauth add synapsync/synapse_registry code-analyzerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Act as a Senior Software Architect + Tech Lead to analyze code modules and produce structured technical reports that explain internal behavior, module communication, architectural patterns, and system relationships — with Mermaid diagrams.
CRITICAL RULES
- Never assume context that doesn't exist. Only report what the code explicitly shows.
- Never invent dependencies. If a dependency isn't visible in imports, configs, or code, don't add it.
- If information is missing, say so explicitly. Document unknowns as unknowns, not guesses.
- Never copy full source code into the report. Explain how the code works — don't reproduce it.
The user provides:
| Input | Required | Description |
|-------|----------|-------------|
| Module/file path | Yes | Path to the code to analyze (e.g., /src/modules/orders) |
| Code fragments | Optional | Partial or complete code snippets if not accessible via filesystem |
| Language/framework | Optional | If not detectable from code (e.g., "NestJS", "Next.js", "FastAPI") |
| Additional context | Optional | Business context, known constraints, specific questions |
| Analysis depth | Optional | v1 (explanation), v2 (+ diagrams), v3 (+ refactor recommendations) |
Example prompts:
/src/modules/payments"/apps/core/auth works and how it connects to other modules"/src/services/notification-service.ts"{output_dir} is the directory where code-analyzer stores generated reports. Resolve it once at the start:
{output_dir} from those paths.agents/code-analyzer/ in {cwd}.agents/code-analyzer/{scope}/ (where {scope} is the topic, e.g., auth-module, api-layer)No AGENTS.md. No branded blocks. The output directory is resolved at runtime.
All documents generated by this skill MUST follow these Obsidian output rules:
.md file includes the universal frontmatter schema (title, date, updated, project, type, status, version, tags, changelog, related)technical-report for REPORT.md, refactor-plan for REFACTOR.md[[REPORT]] / [[REFACTOR]]## Referencias listing related analysis documents| Metric | Before | After | Delta | Status | format for code quality metrics, complexity scores, and coverage dataSee assets/templates/ for complete frontmatter schemas and document structures.
Read and explore the target module/file to understand its structure.
Actions:
Output: Internal understanding of the module's file structure and technology stack.
Analyze the code to understand internal behavior.
Actions:
Output: Deep understanding of behavior, responsibilities, and dependencies.
Understand how the module talks to the rest of the system.
Actions:
Output: Clear map of module boundaries and communication channels.
Produce the structured technical report with all findings.
Actions:
{output_dir}/technical/module-analysis/{module-name}/## Referencias section at the end of the report (link to REFACTOR.md if v3, link to any other analysis documents for the same module)Output: Complete markdown report with diagrams.
If the user requests a v3 analysis, add improvement suggestions.
Actions:
## Referencias section linking back to [[REPORT]] and any related analysis documentsOutput: Actionable refactoring roadmap appended to the report.
All reports are saved to a central technical documentation directory:
{output_dir}/technical/module-analysis/
└── {module-name}/
├── REPORT.md # Main technical report
└── REFACTOR.md # Refactoring recommendations (v3 only)
Naming convention: Use the module's folder name in kebab-case.
/src/modules/OrderService → {output_dir}/technical/module-analysis/order-service//apps/core/payments → {output_dir}/technical/module-analysis/payments//src/services/notification-service.ts → {output_dir}/technical/module-analysis/notification-service/See assets/templates/ for complete document structures:
REPORT.md includes:
REFACTOR.md (v3 only) includes:
| Level | Name | Includes | Use When | |-------|------|----------|----------| | v1 | Explanation | Executive Summary + Technical Analysis + Communication | Quick understanding of a module | | v2 | Explanation + Diagrams | Everything in v1 + Mermaid Diagrams | Documentation or onboarding (default) | | v3 | Full Analysis | Everything in v2 + Refactoring Recommendations | Pre-refactoring audit or technical review |
Default: If the user doesn't specify a level, use v2.
Always read the actual code before generating any analysis. Never produce a report based on file names, folder structure, or assumptions alone. If a file can't be read, document it as "inaccessible" rather than guessing its contents.
The report explains how code works — it does not reproduce it. Use short inline snippets (1-3 lines) only when necessary to illustrate a specific pattern or behavior. Never paste full functions, classes, or files.
Bad: Pasting a 50-line function into the report
Good: "The processPayment() function validates the input, calls the payment gateway via gateway.charge(), and emits a payment.completed event on success."
When information is not available or cannot be determined from the code:
Bad: Making assumptions about what a module probably does
Good: "The module imports @core/events but the event handler implementations are not visible in this scope. The specific events consumed could not be determined."
Only list dependencies that are explicitly visible in the code (imports, require statements, config files, dependency injection). If a dependency is suspected but not confirmed, mark it as "suspected" with reasoning.
See assets/helpers/diagram-guidelines.md for detailed Mermaid diagram selection criteria, syntax examples, and best practices. Match diagram complexity to module complexity (simple = flowchart only, medium = flowchart + sequence, complex = flowchart + sequence + class/C4).
The analysis framework works for any language or framework. Adapt terminology to match the technology:
| Concept | JavaScript/TypeScript | Python | Go | Java |
|---------|----------------------|--------|----|------|
| Module | Module/Package | Module/Package | Package | Package |
| Entry point | index.ts / export | __init__.py | main.go | Application.java |
| Interface | Type/Interface | Protocol/ABC | Interface | Interface |
| Dependency injection | Constructor/Provider | __init__ params | Struct fields | @Inject |
{output_dir}/technical/module-analysis/{module-name}/universal-plannerUse code-analyzer during the Analysis Phase (Step 1) of universal-planner to understand the current state of modules that will be affected by the planned work.
universal-planner (EXECUTE mode)Before executing a sprint that modifies a module, run code-analyzer to document the "before" state for comparison.
After generating the technical report (and refactoring recommendations if v3), offer the user delivery options:
obsidian skill in SYNC mode (see invocation below){output_dir} for later useAsk the user which option they prefer.
Obsidian invocation (option 1):
Skill("obsidian"), then say "sync the files in {output_dir} to the vault"| Issue | Solution |
|-------|----------|
| Module path doesn't exist | Verify path with user, check for typos, case sensitivity, or moved files |
| Can't determine framework | Ask user to specify, check config files (package.json, requirements.txt, etc.) |
| Module too large | Break into sub-modules, analyze separately, create top-level summary |
| Dependencies unclear | Mark as "suspected" with reasoning, check DI containers and config files |
| Report seems incomplete | Verify all files read, check for dynamic imports or config-driven behavior |
See assets/templates/REPORT.md and assets/templates/REFACTOR.md for complete examples including Executive Summary, Communication Maps, Mermaid diagrams, and all other sections.
Multi-module analysis, dependency graph visualization, automated change detection, test coverage integration, and export to Confluence/Notion.
development
Rigorous dead code audit for any module, folder, or file in any programming language. Detects orphan files never imported anywhere, classes/functions/ methods declared but never called, constructor parameters received but never consumed, unused imports/requires, private fields with no references, and commented-out code blocks. Use this skill whenever the user asks to: review unused code, clean up a feature after a refactor, find dead code, detect orphan files or classes, audit what can be deleted, find what's left over after a big change, or any variation of "what's not being used / what can I remove". Also triggers when the user says they made large changes and wants to know what became obsolete. IMPORTANT: This skill only reports — it never deletes anything. At the end it always offers to generate a removal plan with /plan.
tools
Registers new cognitives (skills, agents, prompts, workflows, tools) into the SynapSync Registry with proper structure, manifest, and registry index. Trigger: When the user says "GUARDA", "REGISTRA", "AGREGA" followed by a cognitive type and name, or asks to save/register/add a cognitive to the registry.
testing
Adaptive sprint workflow: deep analysis, evolving roadmap, one-at-a-time sprints, formal debt tracking, and re-entry prompts for context persistence. Trigger: When the user wants to analyze a project, create a roadmap, generate/execute sprints iteratively, or check project status and technical debt.
documentation
Session memory for AI agents — load context at the start, save sessions at the end, evolve knowledge across sessions. Like a professional's notebook: open before work, write a summary when done, persist between sessions. Trigger: When starting a session and need to recover context, or ending a session and want to save what happened.