Thank you for your interest in contributing to CLX (Claude Code Extension Layer). This document covers everything you need to get started.
- Prerequisites
- Project Architecture
- Building
- Testing
- Code Style
- Commit Format
- Pull Request Process
- Reporting Issues
Before contributing, ensure you have the following installed:
Required:
- Rust toolchain (edition 2024) — install via rustup
cargo fmtandcargo clippy(included with standard Rust toolchain)
Required for LLM features:
- Ollama running locally or via Docker
- Models pulled:
qwen3:1.7b(or compatible) for command validation and context summarizationqwen3-embedding:0.6bfor semantic search / vector embeddings
Optional:
- Docker and Docker Compose (for the bundled Ollama setup in
scripts/)
To verify your Rust installation supports edition 2024:
rustc --version # should be 1.85.0 or later
cargo --versionCLX is a Cargo workspace with four crates. Understanding the boundaries helps you place new code correctly.
| Crate | Role | Key contents |
|---|---|---|
clx |
CLI entry point and dashboard | commands/, dashboard/ |
clx-core |
Core library shared by all crates | config, policy/, storage/, ollama, embeddings, credentials, paths, types, error |
clx-hook |
Hook handler binary (PreToolUse / PostToolUse / PreCompact / SessionStart / SessionEnd) | hooks/, audit, learning, transcript, context, embedding |
clx-mcp |
MCP server exposing CLX tools to Claude Code | server, protocol/, tools/ (7 tools), validation |
Guiding principles:
clx-coremust remain free of binary-only concerns.- Each hook handler in
clx-hook/src/hooks/has one responsibility. - MCP tool implementations live in
clx-mcp/src/tools/, one file per tool. - Business logic belongs in
clx-core; I/O belongs at the edges.
Build all crates in release mode:
cargo build --release --workspaceBuild a single crate:
cargo build -p clx
cargo build -p clx-hook
cargo build -p clx-mcpInstall binaries locally (mirrors the install.sh script):
cargo install --path crates/clx
cargo install --path crates/clx-hook
cargo install --path crates/clx-mcpRun the full test suite:
cargo test --workspaceRun tests for a single crate:
cargo test -p clx-coreRun a specific test by name:
cargo test -p clx-core policy::tests::test_whitelist_matchNotes on integration tests:
- Some integration tests require Ollama to be running. They are gated behind the
integrationfeature or will be skipped automatically when Ollama is unavailable. - Tests that depend on environment variables are serialized with
serial_testto avoid flaky failures under parallel execution.
CLX enforces strict code quality standards. All of the following must pass before a PR can be merged.
Formatting:
cargo fmt --all -- --checkTo auto-format (do this before committing):
cargo fmt --allLinting — clippy::pedantic is enabled project-wide:
cargo clippy --workspace --all-targets -- -D warningsZero warnings are acceptable. If a lint is a false positive, suppress it with #[allow(...)] on the smallest possible scope and add a comment explaining why.
Additional style rules:
- Prefer immutability (
letoverlet mutwhere possible). - Use descriptive names; avoid abbreviations except for well-known conventions (
fn,impl,pub). - Keep functions small and single-purpose. Methods over ~40–60 lines are a signal to split.
- Error paths are first-class: use
clx_core::Errorand propagate with?. - No
unwrap()orexpect()in library code — use proper error handling. expect()is acceptable in tests with a message explaining the invariant.
CLX uses a structured commit format. Each commit message must follow:
<type>(<scope>): <summary>
Types:
| Type | When to use |
|---|---|
feat |
A new feature |
fix |
A bug fix |
refactor |
Code change that neither fixes a bug nor adds a feature |
test |
Adding or updating tests |
docs |
Documentation only changes |
chore |
Maintenance, dependency updates, build changes |
perf |
A code change that improves performance |
Scope is the affected crate or module, e.g. clx-core, clx-hook, policy, dashboard.
Rules:
- Summary is imperative mood ("add feature", not "added feature")
- Under 72 characters total
- No signatures, trailers, or AI attribution
Examples:
feat(clx-mcp): add rate limiting to recall tool
fix(policy): handle empty command string in whitelist check
refactor(clx-core): extract credential storage to dedicated module
test(clx-hook): add pre_tool_use integration tests
docs(contributing): clarify Ollama setup requirements
-
Fork the repository and create a feature branch from
main:git checkout -b feat/my-feature
-
Make your changes, keeping commits focused and following the commit format above.
-
Ensure all checks pass locally before pushing:
cargo fmt --all cargo clippy --workspace --all-targets -- -D warnings cargo test --workspace -
Push your branch and open a Pull Request against
mainon GitHub. -
In your PR description, include:
- What problem this solves or feature it adds
- How you tested it
- Any trade-offs or follow-up work you are aware of
-
A maintainer will review your PR. Please respond to review comments promptly. Discussions should be resolved before merging.
-
PRs are merged via squash-merge to keep the
mainhistory clean.
Before opening an issue, please search existing issues to avoid duplicates.
When reporting a bug, include:
- CLX version (
clx --version) - Rust toolchain version (
rustc --version) - Operating system and version
- Ollama version and models in use (if relevant)
- Steps to reproduce
- Expected behavior vs actual behavior
- Any relevant logs (from
~/.clx/logs/or stderr withCLX_LOG=debug)
For feature requests, describe the problem you are trying to solve rather than jumping straight to a proposed solution — this helps the maintainers understand the use case.
For security issues, do NOT open a public issue. Please report them through GitHub Security Advisories.