Generates SHANNON_INDEX for 94% token reduction (58K → 3K tokens). Compresses large codebases into structured summaries with Quick Stats, Tech Stack, Core Modules, Dependencies, Recent Changes, and Key Patterns. Enables fast agent onboarding, efficient multi-agent coordination, and instant context switching. Use when: starting project analysis, onboarding new agents, coordinating waves, switching between codebases, or when context window efficiency is critical.
Generates a compressed SHANNON_INDEX for your codebase, achieving 94% token reduction (58K → 3K tokens). Use this at the start of any project analysis or when onboarding new agents to instantly provide structured context instead of exploring files linearly.
/plugin marketplace add krzemienski/shannon-framework/plugin install shannon@shannon-frameworkThis skill is limited to using the following tools:
examples/baseline-scenarios.mdexamples/compliance-testing.mdexamples/large-project-index.mdexamples/pressure-scenarios.mdtemplates/SHANNON_INDEX.mdPurpose: Shannon's codebase compression system that achieves 94% token reduction (58K → 3K tokens) by generating structured SHANNON_INDEX files. Transforms linear file-by-file exploration into instant structured lookups, enabling fast agent onboarding, efficient multi-agent coordination, and sustainable context window usage.
ROI Proven: 40,000+ tokens saved per project analysis, 12-60x speedup, eliminates redundant file reads in multi-agent scenarios.
Use this skill when:
DO NOT use when:
Required:
project_path (string): Absolute path to project root directoryOptional:
include_tests (boolean): Include test file statistics (default: true)git_days (int): Number of days of git history to include (default: 7)max_dependencies (int): Maximum dependencies to list (default: 10)custom_sections (array): Additional sections to include beyond standard 7CRITICAL: Agents systematically rationalize skipping project indexing, leading to massive token waste. Below are the 6 most common rationalizations detected in baseline testing, with mandatory counters.
Example: User asks "Where is authentication logic?" → Agent thinks "Just need auth files, no need for full index"
COUNTER:
Rule: Generate index first. Even "focused" questions benefit from structure map.
Example: Agent sees 200K token limit → thinks "Plenty of space, can load files directly"
COUNTER:
Rule: Context window size doesn't eliminate need for compression. Generate index.
Example: Agent explores codebase once → thinks "I know where things are now, don't need index"
COUNTER:
Rule: Mental models are session-local and agent-specific. Index is persistent and shareable.
Example: Agent thinks "Files are only 200-500 tokens each, reading is cheap"
COUNTER:
Rule: Per-file cheapness is illusion. Total cost is massive. Generate index.
Example: Agent sees 50 files → thinks "Small enough to explore manually, index overkill"
COUNTER:
Rule: "Small" is relative. All projects benefit from compression. Generate index.
Example: User asks simple question → Agent thinks "Quick answer, don't need full index"
COUNTER:
Rule: Quick questions justify index more, not less. Generate index first.
If you're tempted to:
Then: STOP. Generate SHANNON_INDEX first. Token waste is exponential, not linear.
Count Files by Type
find or Glob to count files per extensionfind . -type f -name "*.ts" | wc -l for each file typeCalculate Total Lines of Code
wc -l on all files by languagefind . -type f -name "*.ts" -exec wc -l {} + | tail -1Identify Tech Stack
Cost: ~500 tokens
Extract Directory Structure
tree -L 2 -d or recursive directory listingIdentify Core Modules
Detect Key Patterns
Cost: ~1,500 tokens (97% compression from full file reads)
Extract Git Recent Changes
git log --since="7 days ago" --pretty=format:"%h - %s" --abbrev-commitAnalyze Key Dependencies
Detect Testing Setup
Cost: ~500 tokens
Generate Quick Stats Section
Generate Tech Stack Section
Generate Core Modules Section
Generate Recent Changes Section
Generate Dependencies Section
Generate Testing Strategy Section
Generate Key Patterns Section
Cost: ~500 tokens
Store in Serena Memory
write_memory("shannon_index_{project_name}", index_content)Write Local Backup
Cost: ~100 tokens
Total Generation Cost: 3,100 tokens
Objective: Discover project structure without loading content
# Count files by type
find . -type f -name "*.ts" | wc -l → typescript_count
find . -type f -name "*.py" | wc -l → python_count
find . -type f -name "*.jsx" | wc -l → jsx_count
# ... repeat for all extensions
# Calculate total lines of code
find . -type f -name "*.ts" -exec wc -l {} + | tail -1 → typescript_lines
# ... repeat for all languages
# Identify tech stack
grep -h "^[^#]" package.json requirements.txt Cargo.toml → dependencies_raw
Token Cost: ~500 tokens (Bash commands + Glob queries)
Output: File counts, language breakdown, total LOC, dependency lists
Objective: Identify core modules and their purposes without reading full files
Strategy:
Directory structure = high-level organization
tree -L 2 -d > structure.txt # 2-level directory tree
Core modules = top-level directories with descriptions
Key patterns = architectural conventions
Token Cost: ~1,500 tokens (directory tree + module summaries + pattern detection)
Compression Ratio: 58K full files → 1.5K structured summaries = 97% reduction
Objective: Add temporal and dependency context
Git Recent Changes (Last 7 Days):
git log --since="7 days ago" --pretty=format:"%h - %s" --abbrev-commit
Key Dependencies (Top 10 by usage):
Testing Setup:
**/*.test.* or tests/Token Cost: ~500 tokens (git log + dependency extraction + testing detection)
Objective: Write structured SHANNON_INDEX.md following template
Template Sections:
Token Cost: ~500 tokens (writing template)
Objective: Save for cross-session retrieval
Serena Storage:
# Save to Serena memory
write_memory(
memory_name="shannon_index_{project_name}",
content=shannon_index_content
)
Local Backup:
# Write to project root
echo "$shannon_index_content" > SHANNON_INDEX.md
Token Cost: ~100 tokens (write operations)
| Phase | Token Cost |
|---|---|
| Project Scan | 500 |
| Architecture Summarization | 1,500 |
| Context Enrichment | 500 |
| Template Population | 500 |
| Persistence | 100 |
| TOTAL | 3,100 tokens |
| Scenario | Without Index | With Index | Savings |
|---|---|---|---|
| Initial load | 58,000 | 3,100 | 54,900 (94%) |
| Subsequent queries | 5,000/query | 50/query | 4,950 (99%) |
| Multi-agent (3 agents) | 64,000 | 3,100 | 60,900 (95%) |
| Context switching | 58,000 | 3,100 | 54,900 (94%) |
ROI: 3,100 token investment → 54,900+ token savings on first use → 17.7x return
# Shannon Project Index
## Quick Stats
- **Total Files**: {count}
- **Primary Languages**: {languages_list}
- **Total Lines of Code**: {loc_total}
- **Last Updated**: {timestamp}
- **Dependencies**: {dep_count}
## Tech Stack
- **Languages**: {languages_with_percentages}
- **Frameworks**: {frameworks_list}
- **Build Tools**: {build_tools}
- **Testing**: {test_framework}
- **Package Manager**: {package_manager}
## Core Modules
{directory_structure_with_purposes}
## Recent Changes (Last 7 Days)
{git_log_commits}
## Key Dependencies
{top_10_dependencies_with_versions}
## Testing Strategy
- **Framework**: {test_framework}
- **Test Location**: {test_file_patterns}
- **Coverage Tool**: {coverage_tool}
- **Test Types**: {unit/integration/e2e}
## Key Patterns
- **Routing**: {routing_approach}
- **State Management**: {state_pattern}
- **Authentication**: {auth_pattern}
- **API Design**: {api_conventions}
- **Error Handling**: {error_patterns}
Template Token Count: ~3,000 tokens when populated
1. Hierarchical Summarization
2. Structural Deduplication
3. Temporal Relevance Filtering
4. Dependency Aggregation
5. Pattern Abstraction
Full Codebase (247 files):
├─ File content: 58,000 tokens
└─ Compressed representation:
├─ Quick Stats: 100 tokens
├─ Tech Stack: 200 tokens
├─ Core Modules: 800 tokens
├─ Recent Changes: 300 tokens
├─ Dependencies: 150 tokens
├─ Testing: 150 tokens
└─ Key Patterns: 400 tokens
TOTAL: 2,100 tokens
Overhead (formatting, markdown): +900 tokens
FINAL INDEX SIZE: 3,000 tokens
REDUCTION: (58,000 - 3,000) / 58,000 = 94.8% ≈ 94%
SHANNON_INDEX.md file containing:
# Shannon Project Index
## Quick Stats
- **Total Files**: 247
- **Primary Languages**: TypeScript (65%), JavaScript (20%), CSS (10%), JSON (5%)
- **Total Lines of Code**: 18,543
- **Last Updated**: 2025-11-03T14:23:00Z
- **Dependencies**: 42
## Tech Stack
- **Languages**: TypeScript 65%, JavaScript 20%, CSS 10%, JSON 5%
- **Frameworks**: React 18.2.0, Next.js 13.4.0
- **Build Tools**: Vite 4.3.0, TypeScript 5.1.0
- **Testing**: Playwright 1.35.0
- **Package Manager**: npm
## Core Modules
- **src/**: Main application source code (React components, hooks, utilities)
- **public/**: Static assets (images, fonts, favicon)
- **tests/**: Playwright functional tests (NO MOCKS)
- **docs/**: Project documentation and guides
- **config/**: Build and deployment configuration
## Recent Changes (Last 7 Days)
- d25b52a - feat(validation): add skill structure validation
- 25b283e - feat(skills): add comprehensive skill template
- f1bf9dc - WIP
- fc93e23 - docs(v4): Add completion SITREP
## Key Dependencies
1. react@18.2.0 - UI framework
2. next@13.4.0 - React framework
3. playwright@1.35.0 - Browser automation
4. typescript@5.1.0 - Type safety
5. vite@4.3.0 - Build tool
## Testing Strategy
- **Framework**: Playwright
- **Test Location**: tests/**/*.spec.ts
- **Coverage Tool**: None
- **Test Types**: E2E functional tests (NO MOCKS)
## Key Patterns
- **Routing**: Next.js file-based routing with App Router
- **State Management**: React Context with custom hooks
- **Authentication**: JWT tokens with NextAuth.js
- **API Design**: REST API with tRPC for type safety
- **Error Handling**: Error boundaries with fallback UI
Serena Memory Storage:
shannon_index_{project_name}read_memory("shannon_index_{project_name}")Metrics:
{
"generation_time_seconds": 120,
"token_cost": 3100,
"original_size_tokens": 58000,
"compressed_size_tokens": 3000,
"compression_ratio": 0.948,
"savings_tokens": 54900,
"roi_multiplier": 17.7
}
This skill succeeds if:
✅ Index generated in < 5 minutes
✅ Compression ratio >= 90%
✅ All 7 sections present and populated
✅ Token count within target range
✅ Stored in Serena memory
shannon_index_{project_name}read_memory()Validation:
def validate_shannon_index(index_content, metrics):
# Verify compression ratio
compression = 1 - (metrics.compressed_size / metrics.original_size)
assert compression >= 0.90, f"Compression ratio {compression:.2%} below 90% target"
# Verify all sections present
required_sections = [
"## Quick Stats",
"## Tech Stack",
"## Core Modules",
"## Recent Changes",
"## Key Dependencies",
"## Testing Strategy",
"## Key Patterns"
]
for section in required_sections:
assert section in index_content, f"Missing required section: {section}"
# Verify token count
assert 1500 <= metrics.compressed_size <= 4500, "Token count outside acceptable range"
# Verify Serena storage
project_name = extract_project_name(index_content)
assert serena.memory_exists(f"shannon_index_{project_name}"), "Index not stored in Serena"
# Verify ROI
assert metrics.roi_multiplier >= 10, f"ROI {metrics.roi_multiplier}x below 10x minimum"
Input:
project_path: "/Users/dev/my-react-app"
include_tests: true
git_days: 7
max_dependencies: 10
Process:
Output:
# Shannon Project Index
## Quick Stats
- **Total Files**: 47
- **Primary Languages**: TypeScript (75%), CSS (15%), JSON (10%)
- **Total Lines of Code**: 3,200
- **Last Updated**: 2025-11-03T15:30:00Z
- **Dependencies**: 15
## Tech Stack
- **Languages**: TypeScript 75%, CSS 15%, JSON 10%
- **Frameworks**: React 18.2.0, Vite 4.3.0
- **Testing**: Jest 29.5.0
- **Package Manager**: npm
## Core Modules
- **src/components/**: React UI components (Button, Input, Modal)
- **src/hooks/**: Custom React hooks (useAuth, useData)
- **src/utils/**: Utility functions (formatDate, validateEmail)
- **tests/**: Jest unit tests
## Recent Changes (Last 7 Days)
- abc123 - feat: add login form component
- def456 - fix: resolve validation bug
- ghi789 - test: add component tests
## Key Dependencies
1. react@18.2.0
2. vite@4.3.0
3. jest@29.5.0
## Testing Strategy
- **Framework**: Jest
- **Test Location**: tests/**/*.test.ts
- **Test Types**: Component tests
## Key Patterns
- **Routing**: React Router v6
- **State Management**: React Context
Metrics:
Input:
project_path: "/Users/dev/enterprise-app"
include_tests: true
git_days: 7
max_dependencies: 10
Process:
Output:
# Shannon Project Index
## Quick Stats
- **Total Files**: 247
- **Primary Languages**: TypeScript (60%), JavaScript (25%), SQL (10%), CSS (5%)
- **Total Lines of Code**: 18,543
- **Last Updated**: 2025-11-03T15:45:00Z
- **Dependencies**: 42
## Tech Stack
- **Languages**: TypeScript 60%, JavaScript 25%, SQL 10%, CSS 5%
- **Frontend**: React 18.2.0, Next.js 13.4.0
- **Backend**: Express 4.18.0, Node.js 18.x
- **Database**: PostgreSQL 15, Prisma ORM 4.15.0
- **Testing**: Playwright 1.35.0, Jest 29.5.0
- **Build**: Vite 4.3.0, TypeScript 5.1.0
## Core Modules
- **frontend/src/**: Next.js application with React components
- **backend/src/**: Express API server with REST endpoints
- **database/**: Prisma schema and migrations
- **tests/e2e/**: Playwright functional tests (NO MOCKS)
- **tests/unit/**: Jest component tests
- **docs/**: API documentation and architecture guides
## Recent Changes (Last 7 Days)
- d25b52a - feat(auth): add OAuth integration
- 25b283e - fix(api): resolve rate limiting issue
- f1bf9dc - test: add E2E checkout flow test
- fc93e23 - docs: update API documentation
- 68dbbd4 - refactor(db): optimize query performance
## Key Dependencies
1. react@18.2.0 - Frontend framework
2. next@13.4.0 - React framework with SSR
3. express@4.18.0 - Backend API server
4. prisma@4.15.0 - Database ORM
5. playwright@1.35.0 - E2E testing
6. jest@29.5.0 - Unit testing
7. typescript@5.1.0 - Type safety
8. zod@3.21.0 - Runtime validation
9. stripe@12.10.0 - Payment processing
10. next-auth@4.22.0 - Authentication
## Testing Strategy
- **Framework**: Playwright (E2E), Jest (Unit)
- **Test Location**: tests/e2e/**/*.spec.ts, tests/unit/**/*.test.ts
- **Coverage Tool**: Istanbul (c8)
- **Test Types**: E2E functional (NO MOCKS), Unit component tests
## Key Patterns
- **Routing**: Next.js App Router with server components
- **State Management**: React Context + Zustand for global state
- **Authentication**: NextAuth.js with OAuth providers (Google, GitHub)
- **API Design**: REST API with tRPC for type-safe endpoints
- **Database**: Prisma ORM with PostgreSQL, migrations via Prisma Migrate
- **Error Handling**: Error boundaries (frontend), global error middleware (backend)
Metrics:
User: "Analyze the Shannon Framework codebase"
Agent (WITH SKILL):
1. Invoke @skill project-indexing
2. Generate SHANNON_INDEX (3,100 tokens)
3. Read SHANNON_INDEX (3,000 tokens)
4. Answer user question (200 tokens)
TOTAL: 6,300 tokens
Agent (WITHOUT SKILL):
1. Glob all files (1,000 tokens)
2. Read 50+ files to understand structure (58,000 tokens)
3. Answer user question (200 tokens)
TOTAL: 59,200 tokens
SAVINGS: 52,900 tokens (89% reduction)
Wave Coordinator: "Launch 3 agents for parallel implementation"
Agents (WITH SKILL):
1. Coordinator generates SHANNON_INDEX once (3,100 tokens)
2. Each agent reads shared index (3,000 tokens × 3 = 9,000 tokens)
TOTAL: 12,100 tokens
Agents (WITHOUT SKILL):
1. Each agent explores independently:
- Frontend: 18,000 tokens
- Backend: 20,000 tokens
- Testing: 26,000 tokens
TOTAL: 64,000 tokens
SAVINGS: 51,900 tokens (81% reduction)
User: "Bring in SECURITY agent to review authentication"
Security Agent (WITH SKILL):
1. Read SHANNON_INDEX from Serena (3,000 tokens)
2. Locate auth module from Core Modules section (50 tokens)
3. Read auth files identified in index (2,000 tokens)
TOTAL: 5,050 tokens
Security Agent (WITHOUT SKILL):
1. Read package.json (500 tokens)
2. Read README (1,200 tokens)
3. Grep for "auth" (finds 23 files)
4. Read 12 auth files (15,000 tokens)
TOTAL: 16,700 tokens
SAVINGS: 11,650 tokens (70% reduction)
User: "Compare Project A and Project B architectures"
Agent (WITH SKILL):
1. Read SHANNON_INDEX for Project A (3,000 tokens)
2. Read SHANNON_INDEX for Project B (3,000 tokens)
3. Compare Tech Stack sections (500 tokens)
TOTAL: 6,500 tokens
Agent (WITHOUT SKILL):
1. Load Project A files (19,000 tokens)
2. Load Project B files (18,000 tokens)
3. Compare (500 tokens)
TOTAL: 37,500 tokens
SAVINGS: 31,000 tokens (83% reduction)
# Store index for cross-session retrieval
write_memory(
memory_name=f"shannon_index_{project_name}",
content=shannon_index_md
)
# Retrieve in future sessions
index = read_memory(f"shannon_index_{project_name}")
Benefit: Zero-cost context restoration across sessions
1. User provides spec: "Build authentication system"
2. @skill project-indexing generates SHANNON_INDEX
3. @skill spec-analysis uses index to:
- Detect existing auth patterns
- Identify dependencies (JWT, OAuth, etc.)
- Assess codebase familiarity (0.0-1.0)
4. 8D score adjusted based on codebase structure
Benefit: More accurate complexity scoring with project context
1. @skill wave-orchestration creates wave plan
2. Each wave agent receives SHANNON_INDEX in context
3. Agents use index to:
- Locate relevant modules
- Identify dependencies
- Avoid duplicate exploration
4. Wave completion 3.5x faster with index
Benefit: Efficient multi-agent coordination
| Project Size | Files | LOC | Generation Time |
|---|---|---|---|
| Small | 10-50 | <5K | 30-60 seconds |
| Medium | 50-150 | 5K-20K | 60-120 seconds |
| Large | 150-300 | 20K-50K | 120-180 seconds |
| Extra Large | 300+ | 50K+ | 180-300 seconds |
| Project Size | Without Index | With Index | Savings |
|---|---|---|---|
| Small | 12,000 | 1,500 | 87% |
| Medium | 35,000 | 2,500 | 93% |
| Large | 58,000 | 3,000 | 94% |
| Extra Large | 100,000+ | 4,000 | 96% |
| Query Type | Without Index | With Index | Speedup |
|---|---|---|---|
| "Where is X?" | 3-5 minutes | 5-15 seconds | 12-60x |
| "What changed?" | 5-8 minutes | 10-20 seconds | 15-48x |
| "How does Y work?" | 5-10 minutes | 30-60 seconds | 10-20x |
| "Compare A and B" | 10-15 minutes | 30-60 seconds | 20-30x |
Average Speedup: 25x faster with index
After generating SHANNON_INDEX, verify:
✅ Quick Stats section includes:
✅ Tech Stack section includes:
✅ Core Modules section includes:
✅ Recent Changes section includes:
✅ Key Dependencies section includes:
✅ Testing Strategy section includes:
✅ Key Patterns section includes:
✅ Token count is 2,500-3,500 tokens
✅ Compression ratio is 90-96%
✅ Saved to Serena with key shannon_index_{project_name}
✅ Written to file at {project_root}/SHANNON_INDEX.md
Problem: Trying to summarize every file leads to 10K+ token index
Solution:
Problem: Index without Recent Changes becomes stale
Solution:
Problem: Index lacks architectural insights, forcing agent to explore anyway
Solution:
Problem: Index must be regenerated every session
Solution:
shannon_index_{project_name}Track these metrics to validate skill effectiveness:
Token Reduction: (tokens_without_index - tokens_with_index) / tokens_without_index
Query Response Time: seconds_to_answer_with_index / seconds_without_index
Multi-Agent Efficiency: total_tokens_with_shared_index / sum(tokens_per_agent_without_index)
Context Switching Cost: tokens_to_switch_with_indexes / tokens_to_reload_full_codebases
Generation ROI: tokens_saved_over_session / tokens_spent_generating_index
See examples/large-project-index.md for a complete SHANNON_INDEX example generated from a 247-file codebase, demonstrating 94% token reduction (58K → 3K tokens).
When to Use This Skill:
When to Skip:
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.