|
| 1 | +# CLAUDE.md - Project Context for Claude |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +**bash_setup** is a Bash dotfiles installer and manager that provides install, update, and uninstall commands for shell configuration files. It uses checksum-based change detection and automatic backup management. |
| 6 | + |
| 7 | +## Architecture |
| 8 | + |
| 9 | +- **Language Mode**: Pure Bash (`language_mode: bash`) |
| 10 | +- **Design**: Monolithic single-file architecture |
| 11 | +- **Entrypoint**: `install.sh` (all logic in one file, ~520 lines) |
| 12 | +- **External Dependency**: Requires `common_core` library at `~/.config/bash/lib/common_core/` |
| 13 | + |
| 14 | +## Key Files |
| 15 | + |
| 16 | +| File | Purpose | |
| 17 | +|------|---------| |
| 18 | +| `install.sh` | Main CLI entrypoint with install/update/uninstall commands | |
| 19 | +| `dotfiles/` | Source configuration files to be installed | |
| 20 | +| `tools/check_bash_style.sh` | Bash style enforcement (ShellCheck + custom rules) | |
| 21 | +| `tools/compile.sh` | CI/test/commit/release workflow orchestration | |
| 22 | +| `spec/tool-spec.json` | Formal tool specification (42 requirements) | |
| 23 | +| `spec/architecture-plan.json` | Locked architecture plan with dependency graph | |
| 24 | +| `tests/` | bats test suites (69 total tests) | |
| 25 | +| `tests/independent/` | Independence tests (58 tests, immutable during repair) | |
| 26 | + |
| 27 | +## Commands |
| 28 | + |
| 29 | +```bash |
| 30 | +./install.sh install # Install dotfiles with backups |
| 31 | +./install.sh update # Update only changed files (SHA-256 comparison) |
| 32 | +./install.sh uninstall # Restore original files from backups |
| 33 | +./install.sh --help # Show usage |
| 34 | +./install.sh --version # Show version |
| 35 | +``` |
| 36 | + |
| 37 | +## Development Workflow |
| 38 | + |
| 39 | +```bash |
| 40 | +make fmt # Format with shfmt |
| 41 | +make lint # Run ShellCheck |
| 42 | +make test # Run bats tests |
| 43 | +make style # Comprehensive style check |
| 44 | +make ci # fmt + lint + test |
| 45 | +``` |
| 46 | + |
| 47 | +## Critical Constraints |
| 48 | + |
| 49 | +### Bash Requirements |
| 50 | +- **Version**: Bash 4.0+ required |
| 51 | +- **Strict Mode**: All scripts must use `set -uo pipefail` and `IFS=$'\n\t'` |
| 52 | +- **Banned Patterns**: `set -e`, backticks, `echo -e`, `for f in $(ls)` |
| 53 | + |
| 54 | +### External Dependency |
| 55 | +The tool requires `common_core` library pre-installed: |
| 56 | +``` |
| 57 | +~/.config/bash/lib/common_core/ |
| 58 | +└── util.sh # Provides file::copy, file::restore_old_backup, logging functions |
| 59 | +``` |
| 60 | + |
| 61 | +### File Patterns |
| 62 | +- **Allowed**: `*.sh` scripts with proper shebang and strict mode |
| 63 | +- **Forbidden**: Python files in implementation, `lib/*.sh` modules (monolithic design) |
| 64 | + |
| 65 | +## Testing |
| 66 | + |
| 67 | +- **Framework**: bats (Bash Automated Testing System) |
| 68 | +- **Test Files**: |
| 69 | + - `tests/00_bootstrap.bats` - Repository structure validation |
| 70 | + - `tests/10_install_help.bats` - CLI interface tests |
| 71 | + - `tests/20_preflight.bats` - Preflight checks validation |
| 72 | + - `tests/independent/*.bats` - Independence tests (DO NOT MODIFY during repair loops) |
| 73 | + |
| 74 | +## Pipeline Infrastructure |
| 75 | + |
| 76 | +The `.claude/` directory contains pipeline infrastructure (gitignored): |
| 77 | +- `agents/` - Gate definitions for automated validation |
| 78 | +- `audit-logs/` - Audit trail for pipeline runs |
| 79 | +- `internal/` - Runtime state (run.json, feedback-loop.json) |
| 80 | +- `schemas/` - JSON schemas for validation |
| 81 | + |
| 82 | +### Pipeline Gates |
| 83 | +The project uses a multi-gate pipeline with HARD_VETO enforcement: |
| 84 | +- spec-validator, plan-validator, traceability-gate |
| 85 | +- language-mode-validator, bash-style-enforcer, shellcheck-gate |
| 86 | +- test-author, artifact-policy-gate, release-manager |
| 87 | + |
| 88 | +## Version Information |
| 89 | + |
| 90 | +- **Current Version**: 1.0.0 |
| 91 | +- **Spec SHA256**: `c33e6d1448f61caaf47bbbd4857806bd421391701a0af5cc5e8282fc9c1c4813` |
| 92 | +- **Pipeline Status**: Certified (Pass 1 + Pass 2) |
| 93 | + |
| 94 | +## Important Notes for Claude |
| 95 | + |
| 96 | +1. **Do not create Python files** - This is a bash-only project |
| 97 | +2. **Do not create `lib/*.sh` modules** - Monolithic architecture by design |
| 98 | +3. **Do not modify `tests/independent/`** - These are immutable during repair loops |
| 99 | +4. **Always use strict mode** in new scripts: `set -uo pipefail`, `IFS=$'\n\t'` |
| 100 | +5. **Third-party code** (`dotfiles/bash-preexec.sh`) has `shellcheck disable=all` - don't enforce style on it |
| 101 | +6. **Common patterns**: Use `file::copy`, `file::restore_old_backup` from common_core for file operations |
| 102 | + |
| 103 | +## Quick Reference |
| 104 | + |
| 105 | +```bash |
| 106 | +# Run all checks before committing |
| 107 | +make ci |
| 108 | + |
| 109 | +# Check style compliance |
| 110 | +make style |
| 111 | + |
| 112 | +# Run specific test file |
| 113 | +bats tests/10_install_help.bats |
| 114 | + |
| 115 | +# Format all scripts |
| 116 | +make fmt |
| 117 | +``` |
0 commit comments