🤖 FOR FUTURE AGENTS: This is your complete playbook for working on Agent OS. Read this FIRST before making any changes to avoid critical sync issues that have caused problems in the past.
NEVER edit installed files directly! Always work on source code first.
If you're an AI agent tasked with working on Agent OS, follow this sequence:
- 🔍 UNDERSTAND THE CONTEXT: Read this entire file first
- 🧹 CHECK WORKSPACE: Run
./check-agent-os.shto verify setup - 🚀 START FRESH: Always create a feature branch for changes
- ✅ FOLLOW THE WORKFLOW: Source → Commit → Install → Test
- 📋 VERIFY EVERYTHING: Use the checklists in this document
| Task | Commands to Run |
|---|---|
| Fix a script bug | 1. Edit scripts/filename.sh2. ./setup.sh --overwrite-instructions3. Test: ~/.agent-os/scripts/filename.sh |
| Add new Claude command | 1. Create commands/new-command.md2. Add to setup-claude-code.sh3. ./setup-claude-code.sh --overwrite-commands |
| Update instruction file | 1. Edit instructions/core/filename.md2. ./setup.sh --overwrite-instructions3. Test: Check ~/.agent-os/instructions/core/ |
| Modify installer | 1. Edit setup.sh or setup-claude-code.sh2. Test locally first 3. Verify end-to-end |
Agent OS operates in three distinct contexts that can get out of sync:
- REPO (
~/Projects/agent-os/) - THIS REPOSITORY - The source code we work on - SYSTEM (
~/.agent-os/) - Global framework installation on user machines - PROJECT (
YourProject/.agent-os/) - Project-specific configuration
Source Location → Installation Destination → Purpose
standards/tech-stack.md → ~/.agent-os/standards/tech-stack.md # Tech stack templates
standards/code-style.md → ~/.agent-os/standards/code-style.md # Code style templates
standards/best-practices.md → ~/.agent-os/standards/best-practices.md # Best practices templatesNote: These preserve user customizations unless --overwrite-standards is used
instructions/core/analyze-product.md → ~/.agent-os/instructions/core/analyze-product.md
instructions/core/create-spec.md → ~/.agent-os/instructions/core/create-spec.md
instructions/core/execute-tasks.md → ~/.agent-os/instructions/core/execute-tasks.md
instructions/core/execute-task.md → ~/.agent-os/instructions/core/execute-task.md
instructions/core/plan-product.md → ~/.agent-os/instructions/core/plan-product.md
instructions/meta/pre-flight.md → ~/.agent-os/instructions/meta/pre-flight.mdscripts/workspace-hygiene-check.sh → ~/.agent-os/scripts/workspace-hygiene-check.sh
scripts/project-context-loader.sh → ~/.agent-os/scripts/project-context-loader.sh
scripts/task-validator.sh → ~/.agent-os/scripts/task-validator.sh
scripts/update-documentation.sh → ~/.agent-os/scripts/update-documentation.sh
scripts/update-documentation-wrapper.sh → ~/.agent-os/scripts/update-documentation-wrapper.sh
scripts/lib/update-documentation-lib.sh → ~/.agent-os/scripts/lib/update-documentation-lib.sh
scripts/lib/spec-creator.sh → ~/.agent-os/scripts/lib/spec-creator.sh
scripts/lib/roadmap-sync.sh → ~/.agent-os/scripts/lib/roadmap-sync.sh
scripts/config-resolver.py → ~/.agent-os/scripts/config-resolver.py
scripts/session-memory.sh → ~/.agent-os/scripts/session-memory.sh
scripts/config-validator.sh → ~/.agent-os/scripts/config-validator.sh
scripts/pre-command-guard.sh → ~/.agent-os/scripts/pre-command-guard.sh
scripts/intent-analyzer.sh → ~/.agent-os/scripts/intent-analyzer.sh
scripts/workspace-state.sh → ~/.agent-os/scripts/workspace-state.sh
scripts/context-aware-wrapper.sh → ~/.agent-os/scripts/context-aware-wrapper.sh
scripts/testing-enforcer.sh → ~/.agent-os/scripts/testing-enforcer.sh
scripts/workflow-validator.sh → ~/.agent-os/scripts/workflow-validator.sh
scripts/work-session-manager.sh → ~/.agent-os/scripts/work-session-manager.sh
scripts/commit-boundary-manager.sh → ~/.agent-os/scripts/commit-boundary-manager.sh
scripts/session-auto-start.sh → ~/.agent-os/scripts/session-auto-start.sh
scripts/check-updates.sh → ~/.agent-os/scripts/check-updates.sh
scripts/validate-instructions.sh → ~/.agent-os/scripts/validate-instructions.sh
scripts/project_root_resolver.py → ~/.agent-os/scripts/project_root_resolver.pyworkflow-modules/step-1-hygiene-and-setup.md → ~/.agent-os/workflow-modules/step-1-hygiene-and-setup.md
workflow-modules/step-2-planning-and-execution.md → ~/.agent-os/workflow-modules/step-2-planning-and-execution.md
workflow-modules/step-3-quality-assurance.md → ~/.agent-os/workflow-modules/step-3-quality-assurance.md
workflow-modules/step-4-git-integration.md → ~/.agent-os/workflow-modules/step-4-git-integration.mdtools/aos → ~/.agent-os/tools/aos # Unified CLI toolVERSION → ~/.agent-os/VERSION # Version trackingSource Location → Installation Destination → Purpose
commands/plan-product.md → ~/.claude/commands/plan-product.md
commands/create-spec.md → ~/.claude/commands/create-spec.md
commands/execute-tasks.md → ~/.claude/commands/execute-tasks.md
commands/analyze-product.md → ~/.claude/commands/analyze-product.md
commands/hygiene-check.md → ~/.claude/commands/hygiene-check.md
commands/update-documentation.md → ~/.claude/commands/update-documentation.md
commands/workflow-status.md → ~/.claude/commands/workflow-status.md
commands/workflow-complete.md → ~/.claude/commands/workflow-complete.mdclaude-code/agents/context-fetcher.md → ~/.claude/agents/context-fetcher.md
claude-code/agents/date-checker.md → ~/.claude/agents/date-checker.md
claude-code/agents/file-creator.md → ~/.claude/agents/file-creator.md
claude-code/agents/git-workflow.md → ~/.claude/agents/git-workflow.md
claude-code/agents/test-runner.md → ~/.claude/agents/test-runner.mdhooks/workflow-enforcement-hook.py → ~/.agent-os/hooks/workflow-enforcement-hook.py
hooks/stop-hook.sh → ~/.agent-os/hooks/stop-hook.sh
hooks/user-prompt-submit-hook.sh → ~/.agent-os/hooks/user-prompt-submit-hook.sh
hooks/pre-bash-hook.sh → ~/.agent-os/hooks/pre-bash-hook.sh
hooks/post-bash-hook.sh → ~/.agent-os/hooks/post-bash-hook.sh
hooks/task-status-sync.sh → ~/.agent-os/hooks/task-status-sync.sh
hooks/notify-hook.sh → ~/.agent-os/hooks/notify-hook.sh
hooks/install-hooks.sh → ~/.agent-os/hooks/install-hooks.sh
hooks/claude-code-hooks.json → ~/.agent-os/hooks/claude-code-hooks.json
# Hook utilities
hooks/lib/workflow-detector.sh → ~/.agent-os/hooks/lib/workflow-detector.sh
hooks/lib/git-utils.sh → ~/.agent-os/hooks/lib/git-utils.sh
hooks/lib/context-builder.sh → ~/.agent-os/hooks/lib/context-builder.sh
hooks/lib/evidence-standards.sh → ~/.agent-os/hooks/lib/evidence-standards.sh
hooks/lib/project-config-injector.sh → ~/.agent-os/hooks/lib/project-config-injector.sh
hooks/lib/testing-enforcer.sh → ~/.agent-os/hooks/lib/testing-enforcer.sh
hooks/lib/testing-reminder.sh → ~/.agent-os/hooks/lib/testing-reminder.sh
hooks/lib/workflow-reminder.sh → ~/.agent-os/hooks/lib/workflow-reminder.shSource Location → Installation Destination → Purpose
commands/plan-product.md → .cursor/rules/plan-product.mdc # Cursor rule format
commands/create-spec.md → .cursor/rules/create-spec.mdc # with front-matter
commands/execute-tasks.md → .cursor/rules/execute-tasks.mdc
commands/analyze-product.md → .cursor/rules/analyze-product.mdc
commands/hygiene-check.md → .cursor/rules/hygiene-check.mdc
commands/update-documentation.md → .cursor/rules/update-documentation.mdc
commands/workflow-status.md → .cursor/rules/workflow-status.mdc
commands/workflow-complete.md → .cursor/rules/workflow-complete.mdcSource Location → Installation Destination → Purpose
commands/analyze-product.md → $CODEX_HOME/prompts/analyze-product.md # Default: ~/.codex/prompts/
commands/create-spec.md → $CODEX_HOME/prompts/create-spec.md
commands/execute-tasks.md → $CODEX_HOME/prompts/execute-tasks.md
commands/hygiene-check.md → $CODEX_HOME/prompts/hygiene-check.md
commands/plan-product.md → $CODEX_HOME/prompts/plan-product.md
commands/update-documentation.md → $CODEX_HOME/prompts/update-documentation.md
commands/workflow-status.md → $CODEX_HOME/prompts/workflow-status.md
commands/workflow-complete.md → $CODEX_HOME/prompts/workflow-complete.mdℹ️ Set
CODEX_HOMEbefore runningsetup.shto install into a non-default Codex configuration directory. Use--skip-codex-commandsif you need to bypass Codex prompt installation.
These source files exist but are NOT installed anywhere:
scripts/pre-commit-docs-guard.sh # ❌ NOT INSTALLED BY ANY SCRIPT
scripts/verify-installation.sh # ❌ NOT INSTALLED BY ANY SCRIPThooks/uninstall-hooks.sh # ❌ NOT INSTALLED BY ANY SCRIPT
hooks/agent-os-bash-hooks.json # ❌ NOT INSTALLED BY ANY SCRIPT
hooks/context_aware_hook.py # ❌ NOT INSTALLED BY ANY SCRIPT
hooks/intent_analyzer.py # ❌ NOT INSTALLED BY ANY SCRIPT
hooks/bash_command_validator_example.py # ❌ NOT INSTALLED BY ANY SCRIPThooks/test_*.py # ✓ Test files - correctly excluded
hooks/tests/ # ✓ Test directory - correctly excludedThese files are downloaded but don't exist in source:
# From integrations/setup-subagent-integration.sh (downloaded by setup-claude-code.sh)
# This may not exist in the repository but is referenced in the installerProblem: Developers fix bugs in installed files (~/.agent-os/, ~/.claude/) but don't update source code. Future installs wipe out the fixes.
Solution: ALWAYS work on source code first, then install.
-
EDIT SOURCE CODE (in this repository)
# Work on files in: # - commands/ # - scripts/ # - hooks/ # - instructions/ # - standards/ # - claude-code/agents/
-
COMMIT CHANGES to repository
git add . git commit -m "Fix: Description of the fix" git push
-
INSTALL FROM SOURCE
# Install base system from updated source ./setup.sh --overwrite-instructions --overwrite-standards # Install Claude Code components from updated source ./setup-claude-code.sh --overwrite-commands # Or install from remote repository curl -sSL https://raw.githubusercontent.com/carmandale/agent-os/main/setup.sh | bash -s -- --overwrite-instructions
-
TEST THE INSTALLATION
# Test the aos CLI aos status # Test Claude Code commands # Use /hygiene-check or /plan-product in Claude Code # Test scripts directly ~/.agent-os/scripts/workspace-hygiene-check.sh
-
VERIFY CHANGES TOOK EFFECT
# Compare source and installed files diff scripts/workspace-hygiene-check.sh ~/.agent-os/scripts/workspace-hygiene-check.sh diff commands/plan-product.md ~/.codex/prompts/plan-product.md # Check installed file timestamps ls -la ~/.agent-os/scripts/workspace-hygiene-check.sh ls -la ~/.codex/prompts/plan-product.md
# DON'T edit installed files directly
nano ~/.agent-os/scripts/workspace-hygiene-check.sh # ❌ WRONG
nano ~/.claude/commands/plan-product.md # ❌ WRONG
# DON'T skip source code updates
# Fix bug in installed file but not source = future installs break # ❌ WRONGBefore claiming any fix is complete:
- Changes made to source files in repository
- Source code committed and pushed to main branch
- Version bumped if needed (in
VERSIONfile)
- Ran installer script(s) with overwrite flags
- Verified installed files match source files
- Checked file timestamps to confirm update
- Tested the specific fix in action
- Verified no regression in other functionality
- Tested via appropriate interface (CLI, Claude Code commands, etc.)
- Confirmed fix addresses identified gaps in this document
- No orphaned files in source that aren't installed
- No references to non-existent files in installers
When modifying the installers themselves:
-
Edit installer scripts in repository root:
setup.sh- Base installationsetup-claude-code.sh- Claude Code installationsetup-cursor.sh- Cursor installation
-
Test installer locally:
# Test base installer ./setup.sh --overwrite-instructions --overwrite-standards # Test Claude Code installer ./setup-claude-code.sh --overwrite-commands
-
Verify via remote install (after pushing changes):
# Test remote installation curl -sSL https://raw.githubusercontent.com/carmandale/agent-os/main/setup.sh | bash
Diagnosis: Installer references file that doesn't exist in source Solution:
- Check if file exists in source repository
- If missing, either create it or remove reference from installer
- Update this AGENTS.md document
Diagnosis: Source file not updated or installer not grabbing latest Solution:
- Verify changes exist in source file
- Check file is listed in installer script
- Run installer with overwrite flags
- Check file timestamps in installed location
Diagnosis: Dependency missing or file permissions wrong Solution:
- Check all referenced files exist
- Verify script permissions (
chmod +xneeded) - Test scripts individually before testing full workflow
- Add to appropriate installer (
setup.sh,setup-claude-code.sh, orsetup-cursor.sh) - Update this AGENTS.md mapping section
- Test installation end-to-end
- Document any new gaps in the verification checklist
- Remove from installer scripts
- Update this AGENTS.md mapping section
- Consider migration/cleanup for existing installations
- Test that removal doesn't break dependent functionality
- Source of truth:
VERSIONfile in repository root - Installed version:
~/.agent-os/VERSION(copied from source) - Update process: Increment version in source, commit, then install
🚨 BEFORE MAKING ANY CHANGES:
- Read the entire AGENTS.md file (this file) - don't skip sections
- Check existing issues and PRs to avoid duplicate work
- Verify you understand the three-context problem
- Always test your changes before claiming completion
❌ DON'T: Edit files in ~/.agent-os/ or ~/.claude/ directly
✅ DO: Edit source files in the repository, then install
❌ DON'T: Assume installation worked without testing ✅ DO: Run verification commands after installation
❌ DON'T: Mix multiple unrelated changes in one commit ✅ DO: Create focused commits for specific fixes
❌ DON'T: Skip the feature branch workflow ✅ DO: Always work on feature branches, never commit directly to main
# 1. Edit source file
nano scripts/workspace-hygiene-check.sh
# 2. Install with overwrite
./setup.sh --overwrite-instructions
# 3. Test directly
~/.agent-os/scripts/workspace-hygiene-check.sh
# 4. Verify it matches source
diff scripts/workspace-hygiene-check.sh ~/.agent-os/scripts/workspace-hygiene-check.sh# 1. Create source file
nano commands/new-command.md
# 2. Add to installer
nano setup-claude-code.sh # Add to the commands loop
# 3. Install with overwrite
./setup-claude-code.sh --overwrite-commands
# 4. Verify installation
ls -la ~/.claude/commands/new-command.md# 1. Edit installer
nano setup.sh
# 2. Test locally
./setup.sh --overwrite-instructions --overwrite-standards
# 3. Check status
aos status
# 4. Test remote install (after pushing)
curl -sSL https://raw.githubusercontent.com/carmandale/agent-os/main/setup.sh | bashAlways run these before claiming work is complete:
# Syntax validation
bash -n setup.sh
bash -n setup-claude-code.sh
bash -n setup-cursor.sh
# Installation test
./check-agent-os.sh
# Status verification
~/.agent-os/tools/aos status
# File comparison (for changed files)
diff scripts/filename.sh ~/.agent-os/scripts/filename.shIf you accidentally edit installed files instead of source:
# 1. STOP - don't commit anything yet
# 2. Copy your changes to the source files manually
# 3. Reinstall from source to verify
./setup.sh --overwrite-instructions --overwrite-standards
# 4. Test that your changes work
# 5. Then commit the source changesBefore completing any task:
- Understanding: I read this AGENTS.md file completely
- Source First: I edited source files, not installed files
- Installation: I ran the appropriate installer with overwrite flags
- Testing: I verified the changes work as expected
- Verification: I compared source and installed files to ensure sync
- Quality: I ran syntax checks and status commands
- Documentation: I updated relevant docs if needed
- Branch: I worked on a feature branch, not main
- Commit: I made focused commits with clear messages
# Check overall status
./check-agent-os.sh
~/.agent-os/tools/aos status
# Reinstall everything
./setup.sh --overwrite-instructions --overwrite-standards
./setup-claude-code.sh --overwrite-commands
# Verify file sync
diff commands/plan-product.md ~/.claude/commands/plan-product.md
diff scripts/workspace-hygiene-check.sh ~/.agent-os/scripts/workspace-hygiene-check.sh
# Syntax checks
bash -n setup.sh
bash -n setup-claude-code.sh
# Create feature branch
git checkout -b feature/your-change-descriptionTrack these to ensure quality:
- Files Changed: List all source files modified
- Installation Commands Run: Document which installers were executed
- Tests Passed: Show output of verification commands
- Sync Verified: Prove source and installed files match
- Quality Checks: Show syntax validation results
## Evidence/Test Results/Verification
### Files Modified
- scripts/workspace-hygiene-check.sh (fixed bug in line 42)
- commands/new-feature.md (added new command)
### Installation Process
```bash
$ ./setup.sh --overwrite-instructions
✅ Script installed successfully
$ ./setup-claude-code.sh --overwrite-commands
✅ Commands installed successfully$ diff scripts/workspace-hygiene-check.sh ~/.agent-os/scripts/workspace-hygiene-check.sh
# No output = files match ✅
$ ~/.agent-os/scripts/workspace-hygiene-check.sh
✅ Script executes successfully
$ aos status
✅ All components current$ bash -n setup.sh
✅ Syntax valid
$ ./check-agent-os.sh
🚀 Agent OS is ready to use!
---
**Last Updated:** 2025-01-27
**Document Version:** 2.0.0 - Enhanced for AI Agents
**Next Review:** When source-to-installation mappings change
*🤖 This document is specifically designed for AI agents working on Agent OS. Follow it religiously to avoid sync issues.*