This document provides guidelines for agentic coding assistants (like Claude Code, Cursor, etc.) working on the Halcon CLI codebase. It includes build/lint/test commands, code style conventions, and project-specific patterns.
# Build the main CLI binary (requires momoto submodule)
cargo build -p halcon-cli
# Build without color-science (CI-safe, no submodule)
cargo build -p halcon-cli --no-default-features --features tui
# Build release with color-science
cargo build --release -p halcon-cli
# Build for Linux targets (requires cross + Docker)
./scripts/build-cross.sh x86_64-unknown-linux-musl --release
./scripts/build-cross.sh aarch64-unknown-linux-gnu --release
./scripts/build-cross.sh aarch64-unknown-linux-musl --release
# Install binary to ~/.local/bin/halcon
make install# Check formatting (must pass before commit)
cargo fmt --all -- --check
# Run clippy with all warnings as errors
cargo clippy --workspace --no-default-features -- -D warnings
# Type-check without codegen
cargo check --workspace --no-default-features# Run all workspace tests (CI-safe, no color-science)
cargo test --workspace --no-default-features
# Run color-science tests (requires momoto submodule)
cargo test -p halcon-cli --features color-science --lib
# Run delta-E palette validation
cargo test -p halcon-cli --features color-science --lib \
tui_colors_perceptually_distinct_neon panel_sections_distinguishable \
toast_levels_distinguishable -- --nocapture
# Run full test suite with both feature sets
make test-all
# Run a single test
cargo test -p halcon-cli --lib -- test_name
# Run tests with logging
RUST_LOG=debug cargo test -p halcon-cli --lib -- test_name
# Run integration tests
cargo test -p halcon-cli --test integration_test_name- Formatting: Use
cargo fmtbefore every commit. The CI enforces--check. - Linting:
cargo clippy -- -D warningsmust pass with zero warnings. - Error Handling: No
unwrap()in production paths — use?or explicit error handling. - Async: No
std::sync::Mutexin async functions — usetokio::sync::Mutex. - Logging: Prefer
tracing::overeprintln!/println!in library code.
Group imports in this order:
- Standard library (
std,core,alloc) - External crates (
tokio,serde,anyhow) - Workspace crates (
halcon_core,halcon_tools) - Current crate (
crate::orsuper::) - Module-level imports (
self::)
Use use statements sparingly; prefer fully qualified paths for rarely used types.
- Modules: snake_case (
agent_runtime.rs) - Types: PascalCase (
HalconError,PermissionLevel) - Functions: snake_case (
event_bus,load_config) - Variables: snake_case (
session_id,provider_name) - Constants: SCREAMING_SNAKE_CASE (
DEFAULT_CAPACITY) - Enums: PascalCase with variant PascalCase (
EventPayload::SessionStarted)
- Library crates: Use
thiserrorfor typed errors (HalconError). - Binary crate: Use
anyhowfor context (anyhow::Context). - Result alias:
pub type Result<T> = std::result::Result<T, HalconError>; - Retryable errors: Implement
is_retryable()method on error types.
- Place shared types in
crates/halcon-core/src/types/. - Use
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]where appropriate. - Include
#[serde(default)]for backward compatibility.
- Use
///doc comments for public items. - Include examples for complex functions.
- Mark
// SAFETY:comments for unsafe blocks.
- No new
unsafeblocks without// SAFETY:comment and team review. - Destructive tool operations require explicit user confirmation.
- No credentials, API keys, or tokens in source or tests.
- New tool implementations must go through the FASE-2 security gate in
executor.rs. - Security-sensitive paths require
@cuervo-ai/securityreview:crates/halcon-security/crates/halcon-auth/crates/halcon-sandbox/crates/halcon-tools/src/bash.rs(CATASTROPHIC_PATTERNS)crates/halcon-core/src/security.rs
- Unit tests: Place in the same file using
#[cfg(test)] mod tests { ... }. - Integration tests: Go in
crates/halcon-cli/tests/. - New features require new tests.
- Bug fixes require a regression test.
- No existing tests may be broken.
- Security-sensitive changes require tests in
halcon-security/.
We follow Conventional Commits:
<type>(<scope>): <short description>
[optional body]
[optional footer]
Types: feat, fix, refactor, docs, test, chore, perf, ci
Scopes: repl, tools, mcp, security, context, planning, cli, core, storage, async
Examples:
feat(mcp): add OAuth 2.1 PKCE flow for HTTP servers
fix(async): replace std::sync::Mutex with tokio in model_selector
refactor(repl): migrate planning files to planning/ subdirectory
- Implement
Tooltrait incrates/halcon-tools/src/. - Register in
halcon_tools::full_registry(). - Add to
CATASTROPHIC_PATTERNScheck if the tool can delete/overwrite data. - Write tests for both allowed and blocked cases.
- Implement
ModelProvidertrait incrates/halcon-core/src/traits/. - Add provider config to
crates/halcon-core/src/types/config.rs. - Register in
crates/halcon-cli/src/repl/provider_normalization.rs. - Add integration test in
crates/halcon-cli/tests/.
crates/
├── halcon-cli/ # Main CLI binary + REPL
├── halcon-core/ # Shared types and traits
├── halcon-tools/ # Tool implementations
├── halcon-context/ # Context pipeline + vector store
├── halcon-mcp/ # MCP server implementation
├── halcon-security/ # RBAC, sandboxing
├── halcon-storage/ # SQLite persistence
└── halcon-auth/ # OAuth 2.1 + PKCE
- CONTRIBUTING.md – Detailed contribution guide
- SECURITY.md – Security reporting and policies
- README.md – Project overview and usage
- CI Workflow:
.github/workflows/ci.yml - Makefile:
Makefilefor common tasks
Last updated: March 2025