|
| 1 | +# Contributing to Codebase Optimizer |
| 2 | + |
| 3 | +Guidelines for customizing and extending the codebase-optimizer framework. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Getting Started |
| 8 | + |
| 9 | +1. **Fork or clone** this repository |
| 10 | +2. **Run installation**: `./scripts/install.sh --all` |
| 11 | +3. **Verify setup**: `claude "Run codebase-optimizer on agents/"` |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Customizing Templates |
| 16 | + |
| 17 | +### Adding a New Stack Template |
| 18 | + |
| 19 | +1. Copy the base template: |
| 20 | + ```bash |
| 21 | + cp templates/CLAUDE.md.template templates/CLAUDE-yourstack.md |
| 22 | + ``` |
| 23 | + |
| 24 | +2. Update required sections: |
| 25 | + - **Repository Identity**: Stack-specific description |
| 26 | + - **Tech Stack**: Technologies and versions |
| 27 | + - **Code Conventions**: Stack-specific patterns |
| 28 | + - **Critical Rules**: MUST/MUST NOT for this stack |
| 29 | + - **Known Technical Debt**: Common issues |
| 30 | + - **Common Pitfalls**: Stack-specific gotchas |
| 31 | + |
| 32 | +3. Validate your template: |
| 33 | + ```bash |
| 34 | + ./scripts/validate-templates.sh templates/CLAUDE-yourstack.md |
| 35 | + ``` |
| 36 | + |
| 37 | +### Template Requirements |
| 38 | + |
| 39 | +- All templates must have 50+ lines |
| 40 | +- Required sections (see `validate-templates.sh`): |
| 41 | + - Repository Identity |
| 42 | + - Tech Stack |
| 43 | + - Code Conventions |
| 44 | + - Critical Rules |
| 45 | + - Known Technical Debt |
| 46 | + - Common Pitfalls |
| 47 | +- No placeholder text (`TODO`, `PLACEHOLDER`, `TBD`) |
| 48 | +- Code blocks should have language tags |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +## Adding Custom Agents |
| 53 | + |
| 54 | +### Agent File Structure |
| 55 | + |
| 56 | +Create new agents in `agents/` with this structure: |
| 57 | + |
| 58 | +```markdown |
| 59 | +--- |
| 60 | +name: your-agent-name |
| 61 | +description: Brief description of what the agent does |
| 62 | +tools: |
| 63 | + - Read |
| 64 | + - Grep |
| 65 | + - Glob |
| 66 | + - Bash |
| 67 | +--- |
| 68 | + |
| 69 | +# Your Agent Name |
| 70 | + |
| 71 | +[Full prompt and instructions here] |
| 72 | + |
| 73 | +## Execution Rules |
| 74 | + |
| 75 | +1. Rule one |
| 76 | +2. Rule two |
| 77 | +... |
| 78 | +``` |
| 79 | + |
| 80 | +### Agent Requirements |
| 81 | + |
| 82 | +- Valid YAML frontmatter with `---` delimiters |
| 83 | +- `name` and `description` fields required |
| 84 | +- `tools` array specifying allowed tools |
| 85 | +- Clear execution rules section |
| 86 | +- No hardcoded secrets or API keys |
| 87 | + |
| 88 | +### Testing Your Agent |
| 89 | + |
| 90 | +```bash |
| 91 | +claude "Run your-agent-name on src/" |
| 92 | +``` |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +## Modifying Scripts |
| 97 | + |
| 98 | +### Coding Standards |
| 99 | + |
| 100 | +All shell scripts must: |
| 101 | +- Use `set -e` for error handling |
| 102 | +- Source `bootstrap/lib.sh` for colors and utilities |
| 103 | +- Include usage documentation in header comments |
| 104 | +- Use proper cleanup with `trap` for critical operations |
| 105 | + |
| 106 | +### Shared Library (`bootstrap/lib.sh`) |
| 107 | + |
| 108 | +Use the shared library for: |
| 109 | +- Color codes: `$RED`, `$GREEN`, `$YELLOW`, `$BLUE`, `$NC` |
| 110 | +- Logging: `log_phase`, `log_success`, `log_error`, `log_warning`, `log_info` |
| 111 | +- Banners: `show_banner`, `show_completion_banner` |
| 112 | +- Utilities: `require_command`, `validate_file` |
| 113 | + |
| 114 | +Example: |
| 115 | +```bash |
| 116 | +#!/bin/bash |
| 117 | +set -e |
| 118 | + |
| 119 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 120 | +source "$(dirname "$SCRIPT_DIR")/bootstrap/lib.sh" |
| 121 | + |
| 122 | +log_phase "Starting process" |
| 123 | +log_success "Completed" |
| 124 | +``` |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +## Pull Request Process |
| 129 | + |
| 130 | +1. **Run validation** before submitting: |
| 131 | + ```bash |
| 132 | + ./scripts/validate-templates.sh |
| 133 | + ``` |
| 134 | + |
| 135 | +2. **Run codebase-optimizer** on your changes: |
| 136 | + ```bash |
| 137 | + claude "Run codebase-optimizer on the files I modified" |
| 138 | + ``` |
| 139 | + |
| 140 | +3. **Ensure no regressions**: |
| 141 | + - All scripts have `set -e` |
| 142 | + - No hardcoded secrets |
| 143 | + - Documentation updated if needed |
| 144 | + |
| 145 | +4. **Commit message format**: |
| 146 | + ``` |
| 147 | + <type>: <description> |
| 148 | +
|
| 149 | + Types: feat, fix, docs, refactor, test, chore |
| 150 | + ``` |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +## Windows Users |
| 155 | + |
| 156 | +Shell scripts require Unix-like environment: |
| 157 | +- **Git Bash** (included with Git for Windows) |
| 158 | +- **WSL** (Windows Subsystem for Linux) |
| 159 | +- **Docker** (run scripts in container) |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## Questions? |
| 164 | + |
| 165 | +Open an issue for: |
| 166 | +- Bug reports |
| 167 | +- Feature requests |
| 168 | +- Template suggestions |
| 169 | +- Documentation improvements |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +*Last updated: 2026-01-28* |
0 commit comments