claude-os/scripts
Claude f6a1d6b417
🗂️ ORGANIZE: Reorganize root directory structure
Moved 25 files from root to organized subdirectories while keeping
essential scripts (install.sh, setup.sh, start*.sh, stop*.sh) in root.

## Changes:

### New Directory Structure:
- Created `/scripts/` for utility scripts
- Created `/docs/guides/` for user guides
- Created `/docs/development/` for dev documentation
- Created `/docs/archive/` for historical/legacy docs

### Moved Files:

**To `/scripts/` (7 files):**
- backup_claude_os.sh
- restore_claude_os.sh
- run_tests.sh
- setup_native.sh
- start_mcp_server.sh
- start_redis_workers.sh
- entrypoint.sh

**To `/docs/guides/` (7 files):**
- AUTH_SETUP.md
- BACKUP_RESTORE_GUIDE.md
- HOOK_SETUP_QUICK_START.md
- SHARING_GUIDE.md
- START_SCRIPTS_GUIDE.md
- PORTS_GUIDE.md
- WHAT_IS_CLAUDE_OS.md

**To `/docs/development/` (4 files):**
- COMPREHENSIVE_REVIEW.md
- SECURITY_FIXES.md
- CLAUDE_OS_DEVELOPER_GUIDE.md
- PROJECT_SETUP_AND_COMMANDS.md

**To `/docs/archive/` (10 files):**
- HYBRID_INDEXING_COMPLETE.md
- INITIALIZE_PROJECT_HOOKS_FIX.md
- INSTALL_ENHANCEMENTS.md
- INSTALL_FIXES.md
- PISTN_TEST_RESULTS.md
- SESSION_SUMMARY.md
- TEST_COVERAGE.md
- TEST_RESULTS.md
- TESTING_STATUS.md
- README_TESTING.md

### Updated References:

**Fixed broken documentation links in:**
- docs/QUICK_REFERENCE.md
- docs/PRODUCTION_DEPLOYMENT.md
- docs/SCRIPTS_GUIDE.md
- docs/development/SECURITY_FIXES.md
- docs/guides/BACKUP_RESTORE_GUIDE.md
- docs/development/CLAUDE_OS_DEVELOPER_GUIDE.md
- tests/TESTING_GUIDE.md
- tests/TEST_COVERAGE.md

**Script references updated to:**
- `./scripts/backup_claude_os.sh`
- `./scripts/restore_claude_os.sh`
- `./scripts/run_tests.sh`
- `./scripts/setup_native.sh`
- `./scripts/start_mcp_server.sh`
- `./scripts/start_redis_workers.sh`

### Remaining in Root (9 essential files):
- install.sh
- setup.sh
- start.sh
- start_all_services.sh
- stop_all_services.sh
- restart_services.sh
- README.md
- CLAUDE.md
- requirements.txt (+ GEMINI_DIAGRAM_PROMPT.md)

## Benefits:
✅ Cleaner root directory (9 files vs 34 files)
✅ Organized documentation by purpose
✅ Scripts grouped in dedicated directory
✅ Essential startup commands still in root
✅ All references updated and verified
✅ No broken links

Version: 2.0.2
2025-11-04 21:34:26 +00:00
..
backup_claude_os.sh 🗂️ ORGANIZE: Reorganize root directory structure 2025-11-04 21:34:26 +00:00
entrypoint.sh 🗂️ ORGANIZE: Reorganize root directory structure 2025-11-04 21:34:26 +00:00
generate_diagnostic.sh Fixing the install script for error handling 2025-11-01 14:34:30 -05:00
index-codebase.sh Add codebase indexing helper script 2025-10-30 20:46:43 -05:00
README.md Add codebase indexing helper script 2025-10-30 20:46:43 -05:00
report_error.sh Fixing the install script for error handling 2025-11-01 14:34:30 -05:00
restore_claude_os.sh 🗂️ ORGANIZE: Reorganize root directory structure 2025-11-04 21:34:26 +00:00
run_tests.sh 🗂️ ORGANIZE: Reorganize root directory structure 2025-11-04 21:34:26 +00:00
setup_native.sh 🗂️ ORGANIZE: Reorganize root directory structure 2025-11-04 21:34:26 +00:00
start_mcp_server.sh 🗂️ ORGANIZE: Reorganize root directory structure 2025-11-04 21:34:26 +00:00
start_redis_workers.sh 🗂️ ORGANIZE: Reorganize root directory structure 2025-11-04 21:34:26 +00:00

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/ or documentation/ directory
  • All .md, .txt, .pdf files

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, .xml files

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 bases
  • migrate-project.sh - Migrate project between Claude OS instances
  • export-memories.sh - Export project memories as markdown
  • sync-team-knowledge.sh - Sync knowledge bases across team

Questions or issues? Check the main Claude OS README or open an issue on GitHub.