Skip to content

Commit aeead33

Browse files
TaylorHonakerclaude
andcommitted
Polish: 9.5 → 10/10
- Update CLAUDE.md: Mark bootstrap duplication as RESOLVED, add bats tests as FUTURE enhancement - Centralize color codes: Scripts now source bootstrap/lib.sh instead of defining their own - Add CONTRIBUTING.md: Basic contribution guidelines for templates, agents, and scripts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8f6f95b commit aeead33

5 files changed

Lines changed: 185 additions & 19 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ codebase-optimizer/
7575

7676
| Item | Location | Priority | Notes |
7777
|------|----------|----------|-------|
78-
| Bootstrap script duplication | `bootstrap/` | MEDIUM | 3 scripts share ~60% logic |
78+
| Bootstrap script duplication | `bootstrap/` | RESOLVED | Shared library pattern implemented via `lib.sh` |
7979
| Windows native scripts | `scripts/` | LOW | Requires WSL/Git Bash |
80+
| Bats test suite | `tests/` | FUTURE | Add automated tests for scripts (enhancement) |
8081

8182
---
8283

@@ -129,5 +130,5 @@ claude "Run performance-profiler on lib/"
129130
## Contact
130131

131132
**Owner**: AI Company USA
132-
**Last Updated**: 2026-01-27
133+
**Last Updated**: 2026-01-28
133134
**Review Cycle**: Quarterly

CONTRIBUTING.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
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*

scripts/install.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,8 @@ REPO_DIR="$(dirname "$SCRIPT_DIR")"
6666
CLAUDE_DIR="$HOME/.claude"
6767
AGENTS_DIR="$CLAUDE_DIR/agents"
6868

69-
# Colors
70-
RED='\033[0;31m'
71-
GREEN='\033[0;32m'
72-
YELLOW='\033[1;33m'
73-
BLUE='\033[0;34m'
74-
NC='\033[0m' # No Color
69+
# Source shared library for colors and utilities
70+
source "$REPO_DIR/bootstrap/lib.sh"
7571

7672
# Flags
7773
INSTALL_AGENTS=false

scripts/validate-templates.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414

1515
set -e
1616

17-
# Colors for output
18-
RED='\033[0;31m'
19-
GREEN='\033[0;32m'
20-
YELLOW='\033[1;33m'
21-
NC='\033[0m'
17+
# Source shared library for colors and utilities
18+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19+
source "$(dirname "$SCRIPT_DIR")/bootstrap/lib.sh"
2220

2321
# Required sections for all CLAUDE.md templates
2422
REQUIRED_SECTIONS=(

scripts/weekly-audit.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@
2929

3030
set -e
3131

32+
# Source shared library for colors and utilities
33+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
34+
source "$(dirname "$SCRIPT_DIR")/bootstrap/lib.sh"
35+
3236
REPO_PATH="${1:-.}"
3337
OUTPUT_DIR="${2:-$REPO_PATH/docs/audits}"
3438
DATE=$(date +%Y-%m-%d)
3539
TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S)
3640

37-
# Colors for output
38-
RED='\033[0;31m'
39-
GREEN='\033[0;32m'
40-
YELLOW='\033[1;33m'
41-
NC='\033[0m' # No Color
42-
4341
# ═══════════════════════════════════════════════════════════════════════════════
4442
# Error Recovery Setup
4543
# ═══════════════════════════════════════════════════════════════════════════════

0 commit comments

Comments
 (0)