plugins/deep-dive-analysis/skills/deep-dive-analysis/SKILL.md
AI-powered systematic codebase analysis. Combines structure extraction with semantic understanding to produce documentation capturing WHAT, WHY, HOW, and CONSEQUENCES. Multi-language: Python, Java, JavaScript, TypeScript, SQL, PL/SQL, Rust. Includes pattern recognition, red flag detection, flow tracing, and quality assessment. TRIGGER WHEN: encountering unfamiliar code, before major refactoring, or when documentation is stale or missing DO NOT TRIGGER WHEN: the task is outside the specific scope of this component.
npx skillsauth add acaprino/alfio-claude-plugins deep-dive-analysisInstall 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.
This skill combines mechanical structure extraction with Claude's semantic understanding to produce comprehensive codebase documentation. Unlike simple AST parsing, this skill captures:
| Language | Extensions | Structural extraction | Comment rewriting |
|---|---|---|---|
| Python | .py, .pyi | stdlib ast (always available) | # line + docstrings |
| Java | .java | tree-sitter (preferred) or regex | //, /* */, Javadoc /** */ |
| JavaScript | .js, .mjs, .cjs, .jsx | tree-sitter (preferred) or regex | //, /* */, JSDoc /** */ |
| TypeScript | .ts, .tsx, .mts, .cts | tree-sitter (preferred) or regex; adds interfaces, enums, type aliases | //, /* */, JSDoc /** */ |
| SQL | .sql, .ddl, .dml | regex DDL (tables, views, indexes, sequences, types, functions, procedures, triggers) | --, /* */ |
| PL/SQL (Oracle) | .pks, .pkb, .plsql, .pls, .pck, .prc, .fnc, .trg | regex (packages, package bodies, type bodies, cursors, exceptions, %TYPE/%ROWTYPE references) | --, /* */ |
| Rust | .rs | tree-sitter (preferred) or regex; structs, enums, traits, impls (with Trait for Type naming), mods, unions, type aliases | //, /* */, rustdoc /// / //! / /** */ / /*! */ |
.sql files are disambiguated against PL/SQL by inspecting content for Oracle-specific markers (CREATE OR REPLACE PACKAGE, DBMS_OUTPUT, %TYPE, %ROWTYPE, UTL_FILE, PRAGMA AUTONOMOUS, etc.). PostgreSQL plpgsql is correctly classified as SQL.
The scripts are designed to work out of the box with just the Python stdlib. Tree-sitter is optional and improves accuracy for Java / JavaScript / TypeScript:
# Optional: install for higher-fidelity parsing
pip install -r scripts/requirements.txt
# or
uv pip install -r scripts/requirements.txt
What changes when tree-sitter is installed:
import/export, and CommonJS require.where clauses), impl blocks with trait bounds, attribute macros parsed correctly. Without it, the regex fallback still finds top-level fns, structs/enums/traits/impls/mods, use declarations, and UPPER_CASE constants.ast; SQL/PL-SQL always use the regex DDL extractor.The active parser is reported in ParseResult.notes and in the CLI output: parser=stdlib-ast, parser=tree-sitter, or parser=regex-fallback.
Mechanical Analysis (Scripts):
Semantic Analysis (Claude AI):
Documentation Maintenance:
Use this skill when:
This skill is invoked by the /deep-dive-analysis command. The command creates and manages state automatically in .deep-dive/ under the target directory:
.deep-dive/state.json -- phase tracking (auto-created by the command).deep-dive/<phase-number>-<name>.md -- per-phase output documentsThe legacy standalone flow using analysis_progress.json and DEEP_DIVE_PLAN.md at project root is no longer the primary path -- prefer invoking /deep-dive-analysis <target>.
THE DOCUMENTATION GENERATED BY THIS SKILL IS THE ABSOLUTE AND UNQUESTIONABLE SOURCE OF TRUTH FOR YOUR PROJECT.
ANY INFORMATION NOT VERIFIED WITH IRREFUTABLE EVIDENCE FROM SOURCE CODE IS FALSE, UNRELIABLE, AND UNACCEPTABLE.
[UNVERIFIED - REQUIRES CODE CHECK]file.py::Class.method), never line numbers -- line numbers break on any editSee references/analysis-templates.md for the full verification trust model, temporal purity principle, and documentation status markers.
After analysis completes, consult the right file for your task:
| Your Task | Start With | Also Check | |-----------|-----------|------------| | Onboarding / understanding the project | 07-final-report, 01-structure | 04-semantics | | Writing new feature | 01-structure (Where to Add), 02-interfaces | 04-semantics | | Fixing a bug | 03-flows, 05-risks | 01-structure | | Refactoring | 01-structure, 04-semantics, 05-risks | 03-flows | | Code review | 02-interfaces, 05-risks | 06-documentation | | Updating documentation | 06-documentation, 04-semantics | 02-interfaces |
The analysis NEVER reads or includes contents from sensitive files: .env, .env.*, credentials.*, secrets.*, *.pem, *.key, *.p12, *.pfx, id_rsa*, id_ed25519*, .npmrc, .pypirc, .netrc, or any file containing API keys, passwords, or tokens. If encountered, note file existence only - never quote contents.
# Python
python .claude/skills/deep-dive-analysis/scripts/analyze_file.py \
--file src/utils/circuit_breaker.py \
--output-format markdown
# Java
python .claude/skills/deep-dive-analysis/scripts/analyze_file.py \
--file src/main/java/com/example/UserService.java
# TypeScript
python .claude/skills/deep-dive-analysis/scripts/analyze_file.py \
--file src/services/auth.ts
# SQL / PL-SQL
python .claude/skills/deep-dive-analysis/scripts/analyze_file.py \
--file migrations/0042_users.sql
python .claude/skills/deep-dive-analysis/scripts/analyze_file.py \
--file packages/user_pkg.pkb
Parameters:
--file / -f: Relative path to file - REQUIRED. Any supported extension (see Language Support table).--output-format / -o: Output format (json, markdown, summary) - default: summary--find-usages / -u: Find all usages of exported symbols - default: false--update-progress / -p: Update analysis_progress.json - default: falsepython .claude/skills/deep-dive-analysis/scripts/check_progress.py \
--phase 1 --status pending
python .claude/skills/deep-dive-analysis/scripts/analyze_file.py \
--symbol CircuitBreaker --file src/utils/circuit_breaker.py
python .claude/skills/deep-dive-analysis/scripts/analyze_file.py \
--phase 1 --output-format markdown --output-file docs/01_domains/COMMON_LIBRARY.md
python .claude/skills/deep-dive-analysis/scripts/doc_review.py scan \
--path docs/ --output doc_health_report.json
python .claude/skills/deep-dive-analysis/scripts/doc_review.py validate-links \
--path docs/ --fix
python .claude/skills/deep-dive-analysis/scripts/doc_review.py verify \
--doc docs/agents/lifecycle.md --source src/agents/lifecycle.py
python .claude/skills/deep-dive-analysis/scripts/doc_review.py update-indexes \
--search-index docs/00_navigation/SEARCH_INDEX.md \
--by-domain docs/00_navigation/BY_DOMAIN.md
python .claude/skills/deep-dive-analysis/scripts/doc_review.py full-maintenance \
--path docs/ --auto-fix --output doc_health_report.json
Executes: scan health, validate/fix links, identify obsolete files, update indexes, generate report.
python .claude/skills/deep-dive-analysis/scripts/rewrite_comments.py analyze \
src/main.py --report
python .claude/skills/deep-dive-analysis/scripts/rewrite_comments.py scan \
src/ --recursive --issues-only
python .claude/skills/deep-dive-analysis/scripts/rewrite_comments.py report \
src/ --output comment_health.md
python .claude/skills/deep-dive-analysis/scripts/rewrite_comments.py rewrite \
src/main.py --apply --backup
python .claude/skills/deep-dive-analysis/scripts/rewrite_comments.py standards
| Classification | Criteria | Verification | |---------------|----------|--------------| | Critical | Handles authentication, security, encryption, sensitive data | Mandatory | | High-Complexity | >300 LOC, >5 dependencies, state machines, async patterns | Mandatory | | Standard | Normal business logic, data models, utilities | Recommended | | Utility | Pure functions, helpers, constants | Optional |
| Layer | What | Who Does It | |-------|------|-------------| | 1. WHAT | Classes, functions, imports | Scripts (AST) | | 2. HOW | Algorithm details, data flow | Claude's first pass | | 3. WHY | Business purpose, design decisions | Claude's deep analysis | | 4. WHEN | Triggers, lifecycle, concurrency | Claude's behavioral analysis | | 5. CONSEQUENCES | Side effects, failure modes | Claude's systems thinking |
| Pattern Type | Examples | Documentation Focus | |-------------|----------|---------------------| | Architectural | Repository, Service, CQRS, Event-Driven | Responsibilities, boundaries | | Behavioral | State Machine, Strategy, Observer, Chain | Transitions, variations | | Resilience | Circuit Breaker, Retry, Bulkhead, Timeout | Thresholds, fallbacks | | Data | DTO, Value Object, Aggregate | Invariants, relationships | | Concurrency | Producer-Consumer, Worker Pool | Thread safety, backpressure |
ARCHITECTURE:
- GOD CLASS: >10 public methods or >500 LOC
- CIRCULAR DEPENDENCY: A -> B -> C -> A
- LEAKY ABSTRACTION: Implementation details in interface
RELIABILITY:
- SWALLOWED EXCEPTION: Empty catch blocks
- MISSING TIMEOUT: Network calls without timeout
- RACE CONDITION: Shared mutable state without sync
SECURITY:
- HARDCODED SECRET: Passwords, API keys in code
- SQL INJECTION: String concatenation in queries
- MISSING VALIDATION: Unsanitized user input
1. SCRIPTS RUN FIRST -> classifier.py, ast_parser.py, usage_finder.py
2. CLAUDE ANALYZES -> Read source, apply semantic questions, recognize patterns, identify red flags
3. CLAUDE DOCUMENTS -> Use template, explain WHY not just WHAT, document contracts
4. VERIFY -> Check against runtime behavior, validate with code traces
1. CLASSIFY -> LOC, dependencies, critical patterns, assign classification
2. READ & MAP -> AST structure, classes, functions, constants, state mutations
3. DEPENDENCY CHECK -> Internal imports, external imports, external calls
4. CONTEXT ANALYSIS -> Symbol usages, importing modules, message flows
5. RUNTIME VERIFICATION (Critical/High-Complexity) -> Log analysis, flow verification
6. DOCUMENTATION -> Update progress, generate report, cross-reference
--update-progressThe classic /deep-dive-analysis command runs three subagents in two waves on a single target. For monorepos, multi-language repos, or large codebases where a single deep-dive's context window grows uncomfortable, switch to the team variant:
/deep-dive-analysis:team-deep-dive <target>
The team command:
.deep-dive/01..07.md set that any downstream consumer (/senior-review:team-review, /codebase-mapper:map-codebase, /project-setup:create-claude-md) can pick up without changes..deep-dive/08-interconnect-map.md produced by senior-review:semantic-interconnect-mapper on top of the consolidated set, giving a global Call Graph, Contracts, Invariants, and Integration Hot-Spots view.| Repo profile | Use classic | Use team |
|-----------------------------------------------------|-------------|----------|
| Single package, < 200 files, one language | ✓ | |
| Monorepo (pnpm/npm/yarn/lerna/nx/turbo workspaces) | | ✓ |
| Multi-language (Python + TS, etc.) at top level | | ✓ |
| You want a global interconnection map produced in the same run | | ✓ |
| You want --phase N or --docs-only control | ✓ | |
.deep-dive/
├── state.json
├── partitions/
│ └── <name>/{01..06}.md ← per-partition reports
├── 01-structure.md .. 07-final-report.md ← consolidated (compat with classic)
└── 08-interconnect-map.md ← new, global cross-partition map
See docs/plans/2026-05-20-deep-dive-team-mode-design.md for the full architecture.
references/analysis-templates.md - Verification trust model, temporal purity principle, documentation status markers, comment classification, maintenance workflowsreferences/AI_ANALYSIS_METHODOLOGY.md - Complete analysis methodologyreferences/SEMANTIC_PATTERNS.md - Pattern recognition guidereferences/ANTIREZ_COMMENTING_STANDARDS.md - Comment taxonomyreferences/DEEP_DIVE_PLAN.md - Master analysis plan with all phase definitionstemplates/semantic_analysis.md - AI-powered per-file analysis templatetemplates/analysis_report.md - Module-level report templatescripts/ - analysis tools (Python runtime, multi-language targets)
ast_parser.py - structural extraction dispatcher (Phases 1-7)analyze_file.py - per-file CLI (classification + structure + usages)classifier.py - language-aware criticality classifierusage_finder.py - cross-file symbol usage finder (multi-language extensions)comment_rewriter.py - multi-language comment analysis enginerewrite_comments.py - comment quality CLI (scan / analyze / rewrite / report)doc_review.py - documentation maintenance (Phase 8)check_progress.py / progress_tracker.py - phase progress trackinglanguages/ - per-language adapters (Python ast, Java/JS/TS/Rust via tree-sitter or regex, SQL/PL-SQL regex)
base.py - shared dataclasses + LanguageAdapter Protocol__init__.py - extension dispatch (detect_language, get_adapter)comments.py - per-language comment lexer (includes rustdoc post-processor)_treesitter.py - optional tree-sitter loader with fallbackspython.py, java.py, javascript.py, typescript.py, sql.py, plsql.py, rust.pyrequirements.txt - optional dependencies (tree-sitter + language-pack, click)development
Quality gates for multi-reviewer code review pipelines: adversarial verification panel, completeness critic, reviewer pipeline conventions, and the context sharing pattern for parallel reviewers. TRIGGER WHEN: running /senior-review:team-review quality gates; running /senior-review:code-review Steps 4b/4c (adversarial verification and completeness check); consolidating or deduplicating findings from multiple parallel reviewers. DO NOT TRIGGER WHEN: single-reviewer style review without a consolidation phase, or generic team coordination (the upstream agent-teams skills cover that).
development
Knowledge base for pure-architecture decisions on when to unify duplicated logic into a shared abstraction versus leave it duplicated. Covers the canonical theory (Rule of Three, DRY/WET/AHA, Wrong Abstraction, Locality of Behaviour, Bounded Contexts, Tidy First options framing, CUPID vs SOLID), 12 essential-duplication patterns that justify unification, 12 wrong-abstraction patterns that justify inlining or decomposition, an operational decision frame, and a verified reading list. TRIGGER WHEN: the user is making an architectural decision about whether to centralize, extract, or remove a layer; reviewing an abstraction for premature generality; auditing scattered cross-cutting concerns; spawned by the abstraction-architect agent during /abstraction-architect:audit or as the Abstraction dimension of /senior-review:team-review or /senior-review:code-review; the user asks "should I extract this into a service" / "is this DRY enough" / "is this wrong abstraction". DO NOT TRIGGER WHEN: the task is code formatting and readability cleanup (use clean-code:clean-code), Python-specific refactoring with metrics (use python-development:python-refactor), generic dead-code removal (use senior-review:cleanup-dead-code), security review (use senior-review:security-auditor), or pure pattern-consistency review without an architecture lens (use senior-review:code-auditor).
development
Unified web frontend knowledge base covering CSS architecture, UX psychology, UI components, distinctive aesthetics, and interface design generation. TRIGGER WHEN: working on web styling, design systems, component decisions, responsive strategy, distinctive frontend aesthetics, or exploring multiple interface designs. DO NOT TRIGGER WHEN: the task is purely backend or unrelated to web frontend.
development
Stripe payments knowledge base - API patterns, checkout optimization, subscription lifecycle, pricing strategies, webhook reliability, Firebase integration, cost analysis, and revenue modeling. Loaded by stripe-integrator and revenue-optimizer agents; also consumable directly when the user asks for Stripe-specific patterns without needing an agent. TRIGGER WHEN: working with Stripe API (Payment Intents, Customers, Subscriptions, Checkout Sessions, Connect, webhooks, tax, usage-based billing), pricing strategy, or revenue modeling. DO NOT TRIGGER WHEN: payment work is non-Stripe (PayPal, Square, crypto) or the task is generic e-commerce unrelated to payments.