Deep historical context analysis for code evolution, risk assessment, and pattern compliance. Use BEFORE modifying any code to detect reverts, hotspots, god objects, and required patterns...
CRITICAL: This skill provides proactive intelligence BEFORE code changes to prevent bugs, maintain consistency, and learn from history.
Trigger: User asks to fix, modify, refactor, or change any existing code
Commands to run:
# 1. Smart analysis - CRITICAL for risk assessment
python3 .claude/skills/code_archaeologist/skill.py smart <folder> --question "$ARGUMENTS"
# 2. File analysis - Check if function is a hotspot
python3 .claude/skills/code_archaeologist/skill.py file <file_path> --function <function_name>
# 3. Pattern compliance - Ensure consistency
python3 .claude/skills/code_archaeologist/skill.py pattern-adoption <folder>
What to look for in output:
Trigger: User wants to add new functionality to existing folder
Commands to run:
# 1. Pattern requirements
python3 .claude/skills/code_archaeologist/skill.py pattern-adoption <folder>
# 2. Architecture constraints
python3 .claude/skills/code_archaeologist/skill.py dep-graph <folder>
# 3. Historical context
python3 .claude/skills/code_archaeologist/skill.py smart <folder>
# 4. Optional: Generate design doc with historical intelligence
python3 .claude/skills/code_archaeologist/skill.py design <folder> \
--feature "$FEATURE_NAME" \
--description "$FEATURE_DESC"
Trigger: User asks "why", "how did", "what is the history"
Command to run:
python3 .claude/skills/code_archaeologist/skill.py context <folder> --question "$ARGUMENTS"
Provides:
smart - Adaptive Risk Analysis (MOST IMPORTANT)When: Before ANY code modification What it does: Intelligent analysis with auto-calculated commit limits, risk scoring, revert detection
python3 skill.py smart src/auth --question "Fix OAuth bug"
Output:
Critical for: Preventing repeat failures, understanding risk, knowing what was tried before
file - Function-Level Hotspot DetectionWhen: Before modifying specific functions What it does: Identifies bug-prone functions, complexity growth, coupling
python3 skill.py file src/router.py --function handle_streaming
Output:
Critical for: Knowing if a function is high-risk before touching it
pattern-adoption - Consistency EnforcementWhen: Before adding code to a folder What it does: Shows mandatory patterns, identifies violations
python3 skill.py pattern-adoption src/auth
Output:
Detects 14 patterns: Async/Await, Structured Error Handling, Context Manager, Input Validation, Logging, Decorator, Factory, Dependency Injection, Retry, Caching, Singleton, Observer, Rate Limiting, Circuit Breaker
Critical for: Maintaining codebase consistency
dep-graph - Circular Dependency DetectionWhen: Before refactoring or adding imports What it does: Detects god objects, circular dependencies, fan-in/fan-out
python3 skill.py dep-graph src/auth
Output:
Critical for: Understanding blast radius, avoiding circular imports
context - Historical ContextWhen: User asks "why" questions What it does: Provides targeted historical information
python3 skill.py context src/auth \
--question "Why was JWT authentication chosen?"
Output:
design - Design Doc GenerationWhen: Planning new features What it does: Generates design doc with historical intelligence
python3 skill.py design src/auth \
--feature "OAuth 2.0 Authentication" \
--description "Add OAuth 2.0 support for enterprise customers"
Output:
Critical for: Avoiding past mistakes, learning from similar features
analyze - Standard TimelineWhen: Understanding component evolution What it does: Generates full timeline of folder changes
python3 skill.py analyze src/auth --format markdown
dependencies - Import EvolutionWhen: Understanding dependency history What it does: Tracks when each import was added/removed
python3 skill.py dependencies src/main.py
patterns - Pattern Introduction TimelineWhen: Understanding when patterns were adopted What it does: Shows when each pattern first appeared
python3 skill.py patterns src/router.py
discover - Folder DiscoveryWhen: Exploring unfamiliar codebase What it does: Categorizes and recommends folders to analyze
python3 skill.py discover
python3 skill.py suggest # Top recommendations
User: "Fix the streaming timeout in router.py"
Claude automatically runs:
# Step 1: Risk analysis
python3 skill.py smart src/router --question "Fix streaming timeout"
# Output: "⚠️ CRITICAL RISK:
# - Previous REVERT on 2025-06-14
# - router.py is GOD OBJECT (12 dependents)
# - Risk Score: 87/100"
# Step 2: Function analysis
python3 skill.py file src/router.py --function handle_streaming
# Output: "🔥 HOTSPOT: handle_streaming() modified 47 times"
# Step 3: Pattern requirements
python3 skill.py pattern-adoption src/router
# Output: "MUST use: async (100%), error handling (100%), logging (50%)"
Claude then:
User: "Add OAuth 2.0 authentication to proxy/auth"
Claude automatically runs:
# Step 1: Pattern requirements
python3 skill.py pattern-adoption src/auth
# Output: "Mandatory patterns: Input Validation (83%), Error Handling (100%), Logging (67%)"
# Step 2: Architecture check
python3 skill.py dep-graph src/auth
# Output: "⚠️ WARNING: auth/__init__.py is GOD OBJECT (15 dependents)"
# Step 3: Generate design doc
python3 skill.py design src/auth \
--feature "OAuth 2.0" \
--description "Add OAuth 2.0 authentication"
# Output: Complete design doc with historical context, risks,
# and local prior art references
Claude then:
User: "Why is authentication implemented with JWT instead of sessions?"
Claude automatically runs:
python3 skill.py context src/auth \
--question "Why JWT instead of sessions"
# Output:
# - Historical context from commit messages
# - Design decision from 2024-03: "Use JWT for stateless auth"
# - Similar issues mentioning "session", "jwt", "stateless"
When the skill outputs these warnings, STOP and inform the user:
Meaning: Previous attempts to modify this code failed and were reverted Action:
Meaning: File >2000 lines OR >10 files depend on it Action:
Meaning: Function modified >20 times in history Action:
Meaning: File missing patterns used in >50% of similar files Action:
| Score | Level | Actions Required |
|---|---|---|
| 0-25 | LOW | Standard testing, normal review |
| 26-50 | MEDIUM | Standard testing, careful review |
| 51-75 | HIGH | Feature flag, extra tests, senior review |
| 76-100 | CRITICAL | Feature flag, comprehensive tests, senior + principal review, gradual rollout |
| Adoption | Meaning | Action |
|---|---|---|
| >80% | Strong consensus | MUST use in all new code |
| 50-80% | Established pattern | SHOULD use in new code |
| 20-50% | Emerging pattern | Consider using |
| <20% | Rare/experimental | Optional |
All commands default to analyzing last 500 commits for performance.
No commits found: Ensure you're in a git repository and folder path is correct
Slow performance: Use --format compact or reduce commit depth
Function not found: Function detection uses regex, may not find all functions in complex syntax
Remember: This skill's value is PROACTIVE use BEFORE changes, not reactive use AFTER problems occur. Always run smart analysis before modifying code!