Generate and maintain a project structure index for fast AI navigation. Creates docs/structure.md with an AI-friendly map + tree. Use when starting a new project, after major changes, or when docs/structure.md is stale.
Generate optimized project structure file for fast AI context loading.
docs/structure.mdLocation: docs/structure.md
Purpose: Single source of truth for AI to understand project layout without scanning entire codebase.
This skill includes pre-built scripts that work on all platforms:
# Basic usage (from project root)
node .codex/skills/project-index/scripts/scan-structure.js . 4
# Output to file
node .codex/skills/project-index/scripts/scan-structure.js . 4 > docs/structure.md
# JSON format
node .codex/skills/project-index/scripts/scan-structure.js . 4 json
# Basic usage
python .codex/skills/project-index/scripts/scan_structure.py . 4
# Output to file
python .codex/skills/project-index/scripts/scan_structure.py . 4 > docs/structure.md
# JSON format
python .codex/skills/project-index/scripts/scan_structure.py . 4 json
Option A: Use Built-in Scripts (Recommended)
# Node.js
node .codex/skills/project-index/scripts/scan-structure.js . 4
# Python
python .codex/skills/project-index/scripts/scan_structure.py . 4
Option B: VS Code Tools
# Use list_dir tool recursively
# Use file_search tool with glob patterns
Option C: Native Commands (Platform-specific)
# Linux/macOS
tree -L 4 -I 'node_modules|.git|dist|build' --dirsfirst
# Windows PowerShell
Get-ChildItem -Recurse -Depth 4 | Where-Object { $_.FullName -notmatch 'node_modules|\.git|dist|build' }
# Windows CMD (limited)
dir /s /b /ad
Scan for these important files:
main.*, index.*, app.*, server.**.config.*, *.json, *.yaml, *.toml, .env*README*, CHANGELOG*, docs/***/routes/**, **/api/**, **/controllers/****/components/**, **/views/**, **/pages/****/services/**, **/lib/**, **/utils/****/models/**, **/schema/**, **/migrations/****/*.test.*, **/*.spec.*, **/tests/**Create docs/structure.md with this format:
# Project Structure Index
> Auto-generated by project-index skill. Last updated: YYYY-MM-DD HH:mm
## Quick Stats
- Total files: X
- Main language: TypeScript/Python/etc
- Framework: Next.js/Angular/Express/etc
- Package manager: npm/yarn/pnpm
## Directory Tree
\`\`\`
<tree output here>
\`\`\`
## Key Entry Points
| File | Purpose |
|:---|:---|
| src/index.ts | Main entry |
| src/app.ts | App initialization |
## Config Files
| File | Purpose |
|:---|:---|
| package.json | Dependencies |
| tsconfig.json | TypeScript config |
## Feature Map
| Feature/Domain | Location | Key Files |
|:---|:---|:---|
| Authentication | src/auth/ | login.ts, session.ts, middleware.ts |
| User Management | src/users/ | user.model.ts, user.service.ts |
| API Routes | src/api/ | routes.ts, handlers/ |
| Database | src/db/ | schema.prisma, migrations/ |
| UI Components | src/components/ | Button.tsx, Modal.tsx, Layout.tsx |
## File Patterns
| Looking for | Path pattern |
|:---|:---|
| Components | src/components/**/*.tsx |
| API handlers | src/api/**/*.ts |
| Database models | src/models/**/*.ts |
| Tests | **/*.test.ts, **/*.spec.ts |
| Styles | src/styles/**/*.css |
## Recent Changes (Optional)
- 2024-01-15: Added payment module at src/payment/
- 2024-01-10: Restructured auth to src/auth/
docs/ folder existsdocs/structure.mdIf project prefers JSON, create docs/structure.json:
{
"generated": "2024-01-15T10:30:00Z",
"stats": {
"totalFiles": 150,
"language": "TypeScript",
"framework": "Next.js"
},
"entryPoints": [
{"path": "src/index.ts", "purpose": "Main entry"},
{"path": "src/app.ts", "purpose": "App init"}
],
"features": {
"auth": {
"location": "src/auth/",
"files": ["login.ts", "session.ts", "middleware.ts"]
},
"api": {
"location": "src/api/",
"files": ["routes.ts", "handlers/"]
}
},
"patterns": {
"components": "src/components/**/*.tsx",
"api": "src/api/**/*.ts",
"tests": "**/*.test.ts"
}
}
Structure file should be updated when:
After generating docs/structure.md, AI should:
# Check if structure exists (cross-platform)
test -f docs/structure.md && echo "EXISTS" || echo "NEEDS GENERATION"
# Generate with Node.js script
node .codex/skills/project-index/scripts/scan-structure.js . 4 > docs/structure.md
# Generate with Python script
python .codex/skills/project-index/scripts/scan_structure.py . 4 > docs/structure.md
# Quick check last modified (Linux/macOS)
stat docs/structure.md | grep Modify
# Quick check last modified (PowerShell)
(Get-Item docs/structure.md).LastWriteTime
When generating structure as AI agent:
node .codex/skills/project-index/scripts/scan-structure.js . 4 > docs/structure.md
list_dir tool to scan rootlist_dir recursively on key foldersfile_search with patterns like **/*.tsx, **/*.tsread_file on package.json to detect frameworkSearch for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer