You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Addresses every gap between documented patterns and actual example code.
Changes verified by 40 integration tests and Codex GPT-5.4 review.
Tier 1 — Credibility fixes:
- Add 40 integration tests across 4 test files verifying exit code
contracts (0-4), JSON envelope structure, agent-info manifest accuracy,
and robustness against malformed config
- Add GitHub Actions CI (macOS + Linux)
- Add --quiet global flag (suppresses human output, JSON always emits)
- Replace all hardcoded strings with env!("CARGO_PKG_NAME") / config
- Fix: TTY parse errors now exit 3 (framework code), not 2 (clap code)
- Fix: agent-info/config path work even with malformed config.toml
Tier 2 — Significant improvements:
- Add config loading via figment (3-tier: defaults → TOML → env vars)
- Add config show/path subcommands
- Enrich agent-info with full argument schemas (types, required, defaults,
possible values) so agents can construct calls without guessing
- Add "Getting Started: Build Your Own" section to README
- Enforce --style values via clap value_parser to match agent-info
Tier 3 — Polish:
- Add CI status and MSRV badges to README
- Update AGENTS.md with Ctx pattern, lazy config, standard commands
- Update CONTRIBUTING.md with test suite and project structure
- Clean clippy warnings (zero warnings with -D warnings)
- Hidden contract command for deterministic exit-code testing
- Hermetic tests (temp HOME for skill install)
- Links to additional CLIs built with this architecture.
49
58
50
59
## Guidelines
51
60
52
61
- The example demonstrates the five core patterns plus the entry point, error type, and output helpers. Reusable modules like config loading, secret handling, and HTTP retry are documented as code patterns in the README -- they don't need to be in the example.
53
62
- Keep the example minimal -- it demonstrates patterns, not a real product.
54
63
- Ensure the README, AGENTS.md, and example stay consistent with each other.
64
+
- All new patterns must have corresponding integration tests.
Five patterns turn any Rust CLI into a tool AI agents can pick up and use without documentation, MCP servers, or skill files. The binary describes itself, returns structured output, and uses semantic exit codes. Your CLI becomes the tool, the documentation, and the API -- all in one binary.
Update the `[[bin]]` section and the `#[command(name = "...")]` in `cli.rs`.
644
+
645
+
**3. Replace the `hello` command** with your domain logic. Keep the same structure:
646
+
647
+
```
648
+
src/
649
+
main.rs # Entry point (barely changes between CLIs)
650
+
cli.rs # clap derive definitions
651
+
config.rs # 3-tier config loading
652
+
error.rs # AppError with exit_code(), error_code(), suggestion()
653
+
output.rs # Format detection + envelope helpers
654
+
commands/
655
+
mod.rs
656
+
agent_info.rs # Update: list YOUR commands
657
+
your_command.rs # Your domain logic
658
+
skill.rs # Skill content auto-derived from CARGO_PKG_NAME
659
+
config.rs # config show/path (works out of the box)
660
+
update.rs # Self-update (just change repo owner/name in config)
661
+
```
662
+
663
+
**4. Update `agent-info`** to list your actual commands with argument schemas. This is the contract agents bootstrap from.
664
+
665
+
**5. Write tests and run them:**
666
+
667
+
```bash
668
+
cargo test# All integration tests
669
+
cargo run -- agent-info # Verify manifest
670
+
cargo run -- config show # Verify config loading
671
+
echo'{}'| cargo run -- hello Test # Verify JSON envelope in pipe
672
+
```
673
+
674
+
**6. Ship it:**
675
+
676
+
```bash
677
+
cargo build --release # Single binary, sub-10ms cold start
678
+
./target/release/my-cli skill install # Deploy to Claude/Codex/Gemini
679
+
```
680
+
681
+
The framework conventions (`env!("CARGO_PKG_NAME")`, config loading, skill install) adapt automatically when you rename the package. No find-and-replace needed.
682
+
683
+
---
684
+
622
685
## Example
623
686
624
687
The `example/` directory contains a modular `greeter` CLI demonstrating the five core patterns (agent-info, JSON envelope, semantic exit codes, skill self-install, self-update) and the reusable entry point, error type, and output helpers. Config loading, secret handling, XDG paths, and HTTP retry are documented as code patterns in the Reusable Modules section above -- copy them into your CLI when you need them.
0 commit comments