Skip to content

index

Generate a comprehensive project structure index for faster navigation and context loading. Creates a PROJECT_INDEX.md file mapping the codebase structure.


Analyze the current project and generate a comprehensive index.

Scan the entire project directory structure, excluding:

  • node_modules/
  • .git/
  • __pycache__/
  • dist/, build/, .next/
  • venv/, .venv/
  • Coverage and cache directories

Categorize files by type:

  • Entry Points: Main files, index files, app entry
  • API/Routes: Endpoint definitions
  • Models/Types: Data structures, schemas
  • Services: Business logic
  • Utilities: Helper functions
  • Tests: Test files
  • Configuration: Config files, env templates
  • Documentation: README, docs

Identify:

  • Package managers and dependencies (package.json, requirements.txt, etc.)
  • Internal import relationships between key files
  • External service integrations

Create PROJECT_INDEX.md with this structure:

# Project Index: [Project Name]
Generated: [timestamp]
## Quick Navigation
| Category | Key Files |
|----------|-----------|
| Entry Points | [list] |
| API Routes | [list] |
| Core Services | [list] |
| Models | [list] |
## Directory Structure

[tree view]

## Key Files
### Entry Points
- `[path]` - [description]
### API/Routes
- `[path]` - [description]
### Services
- `[path]` - [description]
### Models/Types
- `[path]` - [description]
## Dependencies
### External
- [package]: [purpose]
### Internal
- [module] → [depends on]
## Architecture Notes
[Brief description of patterns observed]
FlagDescription
--depth=[N]Limit directory depth (default: 5)
--include=[pattern]Include additional patterns
--exclude=[pattern]Exclude additional patterns
--output=[path]Custom output path
Terminal window
/index # Standard index
/index --depth=3 # Shallow index
/index --include="*.graphql" # Include GraphQL files
/index --output=docs/INDEX.md # Custom output location

$ARGUMENTS

If no arguments provided, generate standard index with default settings.


After generating the index, inform the user:

  1. Index file location
  2. Number of files indexed
  3. Key components discovered
  4. Suggest using /load to load specific components into context

This command leverages MCP servers for enhanced indexing:

ALWAYS use Filesystem for project scanning:
- Use list_dir for full structure view
- Use list_directory for targeted exploration
- Use grep_search to find specific patterns
- Use get_file_info for file metadata
Store project structure in knowledge graph:
- Create entities for key modules
- Store component relationships
- Recall structure in future sessions
- Build project understanding over time

Always identify gaps and suggest next steps to users. In case there is no gaps anymore, then AI should clearly state that there is no gap left.