| name | repo |
| description | Create repository context bundles and code maps. Use to share codebase context, generate documentation, and understand project structure. |
Repository Context
Generate context bundles and maps for codebases.
Structure Analysis
Quick Structure
tree -L 2 -I 'node_modules|.git|dist|build'
tree -L 2 -I 'node_modules|.git' --dirsfirst -C
tree -d -L 3 -I 'node_modules|.git'
Detailed Structure
#!/bin/bash
echo "# Repository Structure"
echo ""
echo "## Root Files"
ls -la | grep "^-" | awk '{print "- " $NF}'
echo ""
echo "## Directories"
for dir in */; do
if [[ "$dir" != "node_modules/" && "$dir" != ".git/" ]]; then
echo "### $dir"
ls -la "$dir" | head -10
echo ""
fi
done
Code Maps
Generate Code Map
#!/bin/bash
echo "# Code Map"
echo ""
find src -name "*.ts" -o -name "*.tsx" | while read file; do
echo "## $file"
echo '```typescript'
grep -E "^export (function|const|class|interface|type)" "$file" | head -20
echo '```'
echo ""
done
Function Index
grep -rh "^export function" src/ | sort
grep -rn "^export function" src/ | sort
Class Index
grep -rn "^export class" src/ | sort
grep -rh "^export class\|^\s*\(async \)\?[a-z]\+(" src/ | head -50
Context Bundles
Create Bundle for AI
#!/bin/bash
OUTPUT="CONTEXT.md"
cat > $OUTPUT << 'EOF'
EOF
if [ -f package.json ]; then
echo '```json' >> $OUTPUT
jq '{name, description, main, scripts: .scripts | keys}' package.json >> $OUTPUT
echo '```' >> $OUTPUT
fi
echo "" >> $OUTPUT
echo "## Key Files" >> $OUTPUT
for file in src/index.ts src/main.ts app.ts; do
if [ -f "$file" ]; then
echo "" >> $OUTPUT
echo "### $file" >> $OUTPUT
echo '```typescript' >> $OUTPUT
head -100 "$file" >> $OUTPUT
echo '```' >> $OUTPUT
fi
done
echo "Context bundle created: $OUTPUT"
Smart Pack (Key Files Only)
#!/bin/bash
KEY_PATTERNS=(
"package.json"
"tsconfig.json"
"src/index.ts"
"src/main.ts"
"README.md"
)
for pattern in "${KEY_PATTERNS[@]}"; do
if [ -f "$pattern" ]; then
echo "=== $pattern ==="
cat "$pattern"
echo ""
fi
done
Import Analysis
Dependency Graph
grep -rh "^import.*from" src/ | \
sed "s/.*from ['\"]//; s/['\"].*//" | \
sort | uniq -c | sort -rn | head -20
External Dependencies
grep -rh "^import.*from ['\"]" src/ | \
grep -v "from ['\"]\./" | \
sed "s/.*from ['\"]//; s/['\"].*//" | \
sort | uniq -c | sort -rn
Internal Module Graph
grep -rh "^import.*from ['\"]\./" src/ | \
sed "s/.*from ['\"]//; s/['\"].*//" | \
sort | uniq -c | sort -rn
AI-Powered Analysis
Architecture Summary
STRUCTURE=$(tree -L 2 -I 'node_modules|.git' --dirsfirst)
PACKAGE=$(cat package.json 2>/dev/null)
gemini -m pro -o text -e "" "Analyze this repository structure:
Structure:
$STRUCTURE
package.json:
$PACKAGE
Provide:
1. Architecture pattern used
2. Main entry points
3. Key modules and their purpose
4. Dependencies overview
5. Suggested improvements"
Code Quality Overview
SAMPLES=$(find src -name "*.ts" | head -5 | xargs cat)
gemini -m pro -o text -e "" "Review code quality:
$SAMPLES
Assess:
1. Code organization
2. Naming conventions
3. Error handling
4. Type safety
5. Suggestions"
Documentation Generation
Auto README
gemini -m pro -o text -e "" "Generate a README for this project:
package.json:
$(cat package.json)
Main file:
$(cat src/index.ts | head -100)
Include:
- Description
- Installation
- Usage
- API overview
- Contributing"
API Documentation
EXPORTS=$(grep -rh "^export" src/ | head -50)
gemini -m pro -o text -e "" "Generate API documentation for:
$EXPORTS
Format as markdown with:
- Function signatures
- Parameter descriptions
- Return types
- Example usage"
Best Practices
- Ignore noise - Exclude node_modules, .git, build
- Focus on entry points - Start with main files
- Track dependencies - Understand what's imported
- Use AI for summaries - Large codebases need synthesis
- Keep bundles updated - Regenerate after major changes
- Share context - Help others understand quickly