Created comprehensive indexing script to index entire codebases into Claude OS knowledge bases with a single command. New Files: - scripts/index-codebase.sh: Automated codebase indexing script * Intelligently detects project structure (Rails, Node.js, etc.) * Indexes docs, source code, models, services, controllers, config * Provides progress indicators and statistics * Handles errors gracefully * Can be run locally or on production servers - scripts/README.md: Complete documentation for helper scripts * Usage examples for local and production * Integration with Capistrano, Docker, GitHub Actions * Cron job setup for automatic re-indexing * Troubleshooting guide Updated: - docs/PRODUCTION_DEPLOYMENT.md: * Added section on keeping code index updated * Capistrano hook example for auto-indexing on deploy * Cron job setup for scheduled re-indexing * Performance impact notes Benefits: - One command indexes entire codebase across all knowledge bases - Complete context for Claude (semantic search across all code) - Pattern recognition from your coding style - Better code suggestions matching your architecture - Re-index on every deployment to stay current Usage: ./scripts/index-codebase.sh Pistn /path/to/project http://localhost:8051 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
4.6 KiB
Claude OS Helper Scripts
Utility scripts for managing and operating Claude OS.
Index Codebase Script
index-codebase.sh - Index an entire project codebase into Claude OS knowledge bases.
Usage
./scripts/index-codebase.sh <project_name> [project_path] [claude_os_url]
Examples
Local Development (Mac):
# Index PISTN codebase locally
./scripts/index-codebase.sh Pistn ~/Projects/pistn http://localhost:8051
# Index from current directory
cd ~/Projects/myapp
/path/to/claude-os/scripts/index-codebase.sh MyApp . http://localhost:8051
Production Server:
# Index PISTN on production server
/opt/claude-os/scripts/index-codebase.sh Pistn /var/www/pistn/current http://localhost:8051
# Run after deployment to update index
cd /opt/claude-os
./scripts/index-codebase.sh Pistn /var/www/pistn/current http://localhost:8051
What It Indexes
The script automatically detects and indexes:
1. Documentation → {project}-knowledge_docs
docs/ordocumentation/directory- All
.md,.txt,.pdffiles
2. Application Code → {project}-project_index
app/(Rails, Laravel)src/(Node.js, Go, Rust, modern frameworks)lib/(Ruby gems, libraries)- All code files:
.rb,.py,.js,.ts,.go,.java,.php,.c,.cpp, etc.
3. Models & Database → {project}-project_index
app/models/db/(migrations, schema)
4. Services & Business Logic → {project}-project_index
app/services/services/
5. Controllers & API → {project}-project_index
app/controllers/api/
6. Configuration → {project}-project_profile
config/- All
.yml,.yaml,.json,.xmlfiles
Output
The script provides:
- Progress indicators for each directory
- File counts and success/failure stats
- Final knowledge base statistics
- Next steps and usage examples
Re-indexing
When to re-index:
- After major code changes
- After deployment
- When adding new features
- Weekly for active projects
How to re-index: Simply run the script again with the same parameters. It will update the existing knowledge bases with new/changed files.
# Set up a weekly cron job (production server)
# Add to crontab: crontab -e
0 2 * * 0 /opt/claude-os/scripts/index-codebase.sh Pistn /var/www/pistn/current http://localhost:8051 >> /opt/claude-os/logs/indexing.log 2>&1
Requirements
- Claude OS server must be running
- Curl must be installed
- Read access to project directory
Troubleshooting
"Claude OS server is not responding"
# Check if Claude OS is running
curl http://localhost:8051/health
# Start Claude OS
# Local: cd ~/Projects/claude-os && ./start.sh
# Server: sudo systemctl start claude-os
"Project path does not exist"
# Verify the path is correct
ls -la /path/to/project
# Use absolute path, not relative
./scripts/index-codebase.sh MyApp /full/path/to/project http://localhost:8051
Slow indexing Large codebases (10,000+ files) may take several minutes. This is normal. The script shows progress for each directory.
Benefits
Once indexed, you get:
✅ Semantic code search - Find code by meaning, not just keywords ✅ Complete context - Claude knows your entire codebase ✅ Pattern recognition - Claude learns your coding style ✅ Instant answers - "Where is the appointment logic?" → exact file and line ✅ Better suggestions - Code generation matches your patterns
Integration with Deployment
Capistrano (Rails):
# config/deploy.rb
after 'deploy:finished', 'claude_os:index'
namespace :claude_os do
task :index do
on roles(:app) do
within release_path do
execute "/opt/claude-os/scripts/index-codebase.sh Pistn #{release_path} http://localhost:8051"
end
end
end
end
Docker deployment:
# Dockerfile
RUN /opt/claude-os/scripts/index-codebase.sh MyApp /app http://claude-os:8051
GitHub Actions:
# .github/workflows/deploy.yml
- name: Index codebase in Claude OS
run: |
ssh deploy@server "/opt/claude-os/scripts/index-codebase.sh Pistn /var/www/pistn/current http://localhost:8051"
Future Scripts
Additional utility scripts will be added here:
backup-knowledge-bases.sh- Backup all knowledge basesmigrate-project.sh- Migrate project between Claude OS instancesexport-memories.sh- Export project memories as markdownsync-team-knowledge.sh- Sync knowledge bases across team
Questions or issues? Check the main Claude OS README or open an issue on GitHub.