| name | deep-analysis |
| description | Runs a multi-perspective codebase audit using all mnemex AST commands with PageRank and chain-of-thought reasoning. Use when asked for a deep analysis, full codebase review, or comprehensive audit. |
| allowed-tools | Bash, Task, Read, AskUserQuestion |
| model | opus |
| user-invocable | false |
Deep Code Analysis
This skill provides comprehensive codebase investigation using all mnemex AST analysis commands across multiple dimensions: architecture, implementation, test coverage, reliability, security, performance, and code health.
When to Use This Skill
- Comprehensive audits and full codebase reviews
- Complex bugs spanning multiple systems
- Major refactoring or architecture decision records
- Technical debt assessment and prioritization
- New developer onboarding
- Post-incident root cause analysis
- Security audits
- Multi-perspective investigation when a single dimension is insufficient
Command Reference
| Command | Primary Use |
|---|
mnemex --agent map "query" | Architecture overview with PageRank |
mnemex --agent symbol <name> | Exact file:line location |
mnemex --agent callers <name> | Impact analysis โ what calls this |
mnemex --agent callees <name> | Dependency tracing โ what this calls |
mnemex --agent context <name> | Full call chain (callers + callees) |
mnemex --agent search "query" | Semantic search |
mnemex --agent dependency-graph <name> | Transitive dependency visualization |
In Claude Code with code-analysis plugin, call these as MCP tools directly: map, symbol, callers, callees, context, search, dependency-graph.
PHASE 0: MANDATORY SETUP
Step 1: Verify mnemex
which mnemex && mnemex --version
Step 2: If Not Installed โ STOP
AskUserQuestion({
questions: [{
question: "mnemex v0.3.0+ (AST structural analysis) is required. How would you like to proceed?",
header: "Required",
multiSelect: false,
options: [
{ label: "Install via npm (Recommended)", description: "npm install -g claude-codemem" },
{ label: "Install via Homebrew", description: "brew tap MadAppGang/claude-mem && brew install --cask mnemex" },
{ label: "Cancel", description: "I'll install manually" }
]
}]
})
Step 3: Check Index Status
mnemex --version && ls -la .mnemex/index.db 2>/dev/null
Step 4: Check Index Freshness
if [ ! -d ".mnemex" ] || [ ! -f ".mnemex/index.db" ]; then
exit 1
fi
STALE_COUNT=$(find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.py" -o -name "*.go" -o -name "*.rs" \) \
-newer .mnemex/index.db 2>/dev/null | grep -v "node_modules" | grep -v ".git" | grep -v "dist" | grep -v "build" | wc -l)
STALE_COUNT=$((STALE_COUNT + 0))
if [ "$STALE_COUNT" -gt 0 ]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
INDEX_TIME=$(stat -f "%Sm" -t "%Y-%m-%d %H:%M" .mnemex/index.db 2>/dev/null)
else
INDEX_TIME=$(stat -c "%y" .mnemex/index.db 2>/dev/null | cut -d'.' -f1)
fi
INDEX_TIME=${INDEX_TIME:-"unknown time"}
STALE_SAMPLE=$(find . -type f \( -name "*.ts" -o -name "*.tsx" \) \
-newer .mnemex/index.db 2>/dev/null | grep -v "node_modules" | grep -v ".git" | head -5)
If user proceeds with stale index, display warning:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ WARNING: Index is stale โ results may not reflect recent code changes. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Step 5: Index if Needed
mnemex index
Multi-Dimensional Analysis Framework
Dimension 1: Architecture (map command)
mnemex --agent map
mnemex --agent map "controller handler endpoint"
mnemex --agent map "service business logic"
mnemex --agent map "repository database query"
mnemex --agent map "factory create builder"
mnemex --agent map "interface abstract contract"
mnemex --agent map "event emit subscribe"
Dimension 2: Implementation (callers/callees)
mnemex --agent callees PaymentService
mnemex --agent callers processPayment
mnemex --agent context OrderController
Dimension 3: Test Coverage (callers analysis)
mnemex --agent callers authenticateUser
mnemex --agent map "test spec describe it"
mnemex --agent map "mock stub spy helper"
mnemex --agent callers criticalFunction
Dimension 4: Reliability (context command)
mnemex --agent context handleError
mnemex --agent map "throw error exception"
mnemex --agent callers CustomError
mnemex --agent map "retry fallback circuit"
Dimension 5: Security (symbol + callers)
mnemex --agent symbol authenticate
mnemex --agent callees authenticate
mnemex --agent callers authenticate
mnemex --agent map "permission role check guard"
mnemex --agent map "password hash token secret"
mnemex --agent callers encrypt
Dimension 6: Performance (semantic search)
mnemex --agent search "query database batch"
mnemex --agent map "async await promise parallel"
mnemex --agent map "cache memoize store"
Track feedback for search queries used in this dimension:
PERF_QUERY="query database batch"
PERF_RESULTS=$(mnemex --agent search "$PERF_QUERY")
PERF_HELPFUL=""
PERF_UNHELPFUL=""
if mnemex feedback --help 2>&1 | grep -qi "feedback"; then
timeout 5 mnemex feedback \
--query "$PERF_QUERY" \
--helpful "${PERF_HELPFUL#,}" \
--unhelpful "${PERF_UNHELPFUL#,}" \
2>/dev/null || true
fi
Dimension 7: Code Health (v0.4.0+ Required)
DEAD=$(mnemex --agent dead-code)
if [ -n "$DEAD" ]; then
echo "$DEAD"
else
echo "No dead code found."
fi
GAPS=$(mnemex --agent test-gaps)
if [ -n "$GAPS" ]; then
echo "$GAPS"
for symbol in $(echo "$GAPS" | grep "pagerank: 0.0[5-9]" | awk '{print $4}'); do
mnemex --agent impact "$symbol"
done
else
echo "No test gaps found."
fi
Comprehensive Analysis Workflow
Phase 1: Architecture Mapping
mnemex --agent map
mnemex --agent map "controller route endpoint"
mnemex --agent map "service business domain"
mnemex --agent map "repository data persist"
Phase 2: Critical Path Analysis
mnemex --agent symbol PaymentService
mnemex --agent callees PaymentService
mnemex --agent callers PaymentService
mnemex --agent context PaymentService
Phase 3: Test Coverage Assessment
mnemex --agent callers processPayment
mnemex --agent callers authenticateUser
mnemex --agent callers updateProfile
Phase 4: Risk Identification
mnemex --agent map "auth session token"
mnemex --agent callers validateToken
mnemex --agent map "error exception throw"
mnemex --agent context handleFailure
mnemex --agent map "API external webhook"
mnemex --agent callers stripeClient
Phase 5: Technical Debt Inventory
mnemex --agent search "TODO FIXME deprecated"
mnemex --agent callees LargeService
mnemex --agent callers unusedFunction
Result Validation
After EVERY mnemex command, validate results before proceeding.
Map commands:
RESULTS=$(mnemex --agent map "service layer business logic")
EXIT_CODE=$?
if [ "$EXIT_CODE" -ne 0 ]; then
echo "ERROR: mnemex map failed"
exit 1
fi
if [ -z "$RESULTS" ]; then
echo "WARNING: No symbols found โ may be wrong query or index issue"
fi
if ! echo "$RESULTS" | grep -q "pagerank:"; then
echo "WARNING: No PageRank data โ index may be corrupted or outdated"
fi
All other commands:
RESULTS=$(mnemex --agent [command] [args])
EXIT_CODE=$?
if [ "$EXIT_CODE" -ne 0 ]; then
DIAGNOSIS=$(mnemex --version && ls -la .mnemex/index.db 2>&1)
fi
MATCH_COUNT=0
for kw in $KEYWORDS; do
if echo "$RESULTS" | grep -qi "$kw"; then
MATCH_COUNT=$((MATCH_COUNT + 1))
fi
done
if [ "$MATCH_COUNT" -eq 0 ]; then
fi
Callers for test coverage:
RESULTS=$(mnemex --agent callers $FUNCTION)
if echo "$RESULTS" | grep -qi "error\|not found"; then
fi
FALLBACK PROTOCOL
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ FALLBACK PROTOCOL (NEVER SILENT) โ
โ โ
โ If mnemex fails OR returns irrelevant results: โ
โ โ
โ 1. STOP - Do not silently switch to grep/find โ
โ 2. DIAGNOSE - Run mnemex status to check index health โ
โ 3. COMMUNICATE - Tell user what happened โ
โ 4. ASK - Get explicit user permission via AskUserQuestion โ
โ โ
โ grep/find/Glob ARE FORBIDDEN without explicit user approval โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
AskUserQuestion({
questions: [{
question: "mnemex failed or returned irrelevant results. How should I proceed?",
header: "Investigation Issue",
multiSelect: false,
options: [
{ label: "Reindex codebase", description: "Run mnemex index (~1-2 min)" },
{ label: "Try different query", description: "Rephrase the search" },
{ label: "Use grep (not recommended)", description: "Traditional search โ loses semantic understanding" },
{ label: "Cancel", description: "Stop investigation" }
]
}]
})
If user explicitly chooses grep fallback:
## WARNING: Using Fallback Search (grep)
| Feature | mnemex | grep |
|---------|-----------|------|
| Semantic understanding | Yes | No |
| Call graph analysis | Yes | No |
| PageRank ranking | Yes | No |
| False positives | Low | High |
Recommendation: After completing this task, run `mnemex index` to rebuild the index.
NEVER TRUNCATE CLAUDEMEM OUTPUT
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ OUTPUT TRUNCATION IS FORBIDDEN โ
โ โ
โ FORBIDDEN (any form of output truncation): โ
โ mnemex --agent map "query" | head -80 โ
โ mnemex --agent callers X | tail -50 โ
โ mnemex --agent search "x" | grep -m 10 "y" โ
โ mnemex --agent map "q" | awk 'NR <= 50' โ
โ โ
โ CORRECT (use full output or built-in flags): โ
โ mnemex --agent map "query" โ
โ mnemex --agent search "auth" -n 10 # Built-in limit โ
โ mnemex --agent map "q" --tokens 2000 # Token-limited โ
โ mnemex --agent search "x" --page-size 20 --page 1 # Paginated โ
โ mnemex --agent context Func --max-depth 3 # Depth-limited โ
โ โ
โ WHY: search/map results are sorted by relevance/PageRank. โ
โ Truncating loses the most critical results. โ
โ โ
โ EXCEPTION: head -5 for sampling stale files (freshness check) is valid. โ
โ This prohibition applies only to mnemex command output. โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Output Format: Comprehensive Report
Executive Summary
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CODEBASE COMPREHENSIVE ANALYSIS โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Overall Health: [score]/10 โ
โ Search Method: mnemex (AST + PageRank) โ
โ โ
โ Dimensions: โ
โ โโโ Architecture: [score] [map analysis] โ
โ โโโ Implementation: [score] [callers/callees] โ
โ โโโ Testing: [score] [test-gaps] โ
โ โโโ Reliability: [score] [context tracing] โ
โ โโโ Security: [score] [auth callers] โ
โ โโโ Performance: [score] [async patterns] โ
โ โโโ Code Health: [score] [dead-code + impact] โ
โ โ
โ Critical: N | Major: N | Minor: N โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Architecture (from map)
Core Abstractions (PageRank > 0.05):
โโโ UserService (0.092) - Central business logic
โโโ Database (0.078) - Data access foundation
โโโ AuthMiddleware (0.056) - Security boundary
Layer Structure:
PRESENTATION (src/controllers/)
โโโ UserController (0.034)
โ
BUSINESS (src/services/)
โโโ UserService (0.092) HIGH PAGERANK
โ
DATA (src/repositories/)
โโโ Database (0.078) HIGH PAGERANK
Action Items (Prioritized by PageRank Impact)
IMMEDIATE (This Sprint) โ Affects High-PageRank Code
1. [Critical finding + evidence from mnemex output]
SHORT-TERM (Next 2 Sprints)
2. [Important finding + evidence]
MEDIUM-TERM (This Quarter)
3. [Improvement + evidence]
Feedback Reporting (v0.8.0+)
After completing investigation, report search feedback if search was used:
SEARCH_QUERY="your original query"
HELPFUL_IDS=""
UNHELPFUL_IDS=""
if mnemex feedback --help 2>&1 | grep -qi "feedback"; then
timeout 5 mnemex feedback \
--query "$SEARCH_QUERY" \
--helpful "${HELPFUL_IDS#,}" \
--unhelpful "${UNHELPFUL_IDS#,}" 2>/dev/null || true
fi
| Result Type | Mark As | Reason |
|---|
| Read and used | Helpful | Contributed to investigation |
| Read but irrelevant | Unhelpful | False positive |
| Skipped after preview | Unhelpful | Not relevant to query |
| Never read | (Don't track) | Can't evaluate |
Maintained by: MadAppGang
Plugin: code-analysis v5.0.0
Last Updated: March 2026 (v5.0.0 - Consolidated from deep-analysis + ultrathink-detective)