Developing amplihack¶
Type: How-To (Task-Oriented)
How to set up a local development environment for contributing to amplihack-rs.
Prerequisites¶
- Rust toolchain (1.70+) via rustup.rs
- Node.js 18+ and npm (for Claude Code CLI)
- git 2.0+
Clone and Build¶
Run Tests¶
Project Structure¶
| Directory | Purpose |
|---|---|
crates/ |
Rust crate workspace |
crates/amplihack-cli/ |
Main CLI binary |
amplifier-bundle/ |
Framework assets (agents, recipes, commands) |
docs/ |
Documentation (mkdocs site) |
tests/ |
Integration and end-to-end tests |
Key Crates¶
| Crate | Purpose |
|---|---|
amplihack-cli |
CLI argument parsing and routing |
amplihack-core |
Core types and utilities |
amplihack-agent-core |
Agent runtime and lifecycle |
amplihack-agent-eval |
Evaluation harness |
amplihack-memory |
Memory backend |
amplihack-recipes |
Recipe runner |
Development Workflow¶
1. Create a Feature Branch¶
2. Make Changes¶
Edit Rust code in crates/, framework assets in amplifier-bundle/,
or documentation in docs/.
3. Format and Lint¶
4. Test¶
5. Build Documentation (Optional)¶
6. Commit and Push¶
7. Create Pull Request¶
PRs require:
- All CI checks passing (lint, test, build across 4 targets)
- Documentation updates for user-facing changes
- No regressions in existing tests
Common Tasks¶
Adding a CLI Subcommand¶
- Create a new module in
crates/amplihack-cli/src/commands/ - Register it in
crates/amplihack-cli/src/commands/mod.rs - Add tests in the module's
tests/subdirectory
Adding a Recipe¶
- Create a YAML file in
amplifier-bundle/recipes/ - Define steps with
type: agent,type: shell, ortype: sub_recipe - Test with
amplihack recipe run your-recipe.yaml
Adding an Agent¶
- Create a markdown file in
amplifier-bundle/agents/ - Define the agent's role, tools, and instructions
- Register in the appropriate directory (core, specialized, or workflows)
Troubleshooting¶
Build Failures¶
Test Failures¶
Leaked Rotator Daemons¶
A test that launches amplihack must not leave a profile rotate watch
--spawned process behind. Check after a test run:
See Keep Tests from Leaking Rotator Daemons.
Real Profile Root Changed by a Test Run¶
cargo test -p amplihack-cli fails with real profile root changed during
this test run when a test rewrote a real profile's settings.json. See
Keep Tests out of the Real Profile Root.
Tests That Change PATH or HOME¶
A test that passes alone but fails in a full run with No such file or
directory (os error 2), or runs another test's fake binary, may be seeing a
PATH or HOME that another test set for the whole process. A timeout test
that fails only on a loaded host is measuring the host's speed. Set PATH
and HOME on the child's Command through a seam instead of calling
std::env::set_var, and bound a timeout at 30 s against a fake that ends
with exec /bin/sleep 60. See
Keep Tests from Changing PATH and HOME.
Profile Root Is Not Valid UTF-8 in a Full Run¶
A test that passes alone but fails in a full run with
AMPLIHACK_CLAUDE_PROFILE_ROOT is set but is not valid UTF-8 read the
variable from the process while another test had set it. Pass the
environment as an argument instead. See
Bug Fix #2014.
A Test Run Stops Instead of Failing¶
A run under plain timeout from a terminal can stop, with its processes in
state T, when git asks for credentials. Run long commands as
GIT_TERMINAL_PROMPT=0 setsid -w timeout --kill-after=60 <secs> <command> </dev/null.
Ctrl-C does not stop that form; the guide says how to. See
Keep Tests from Prompting for Git Credentials.
Pre-commit Hook Issues¶
The project uses pre-commit hooks. If they fail:
Related¶
- Prerequisites — detailed tool installation
- Create Your Own Tools — building custom tools
- Code Review — code review practices
- Keep Tests from Leaking Rotator Daemons — test stops and the leak check for
rotate watchdaemons - Keep Tests out of the Real Profile Root — profile-root isolation and the real-root guard
- Keep Tests from Changing PATH and HOME - giving a child process its
PATHandHOME, and bounding timeouts under load - Keep Tests from Prompting for Git Credentials - git prompt settings for tests and amplihack, and running long commands