| Crates.io | conclaude |
| lib.rs | conclaude |
| version | 0.1.1 |
| created_at | 2025-09-05 15:12:23.430631+00 |
| updated_at | 2025-09-05 15:12:23.430631+00 |
| description | Claude Code hook handler CLI tool that processes hook events and manages lifecycle hooks for tool usage, session management, and transcript processing |
| homepage | |
| repository | https://github.com/connix-io/conclaude |
| max_upload_size | |
| id | 1825679 |
| size | 217,084 |
The guardrails your Claude Code sessions need.
A high-performance Rust CLI tool that provides essential guardrails for Claude Code sessions through a comprehensive hook system. Conclaude ensures your AI coding sessions maintain code quality, follow project standards, and respect your development workflows.
Born from real developer frustration, conclaude transforms chaotic AI coding sessions into controlled, validated workflows. It's not just another CLI tool—it's your project's guardian, ensuring that every Claude Code session respects your standards, follows your rules, and maintains your code quality.
AI-assisted coding is revolutionary, but it comes with a challenge: How do you maintain control and quality standards when an AI is making rapid changes to your codebase?
Without guardrails, Claude Code sessions can:
conclaude changes this story.
Imagine starting every Claude Code session knowing that:
✅ Your linting rules will be respected - No more broken formatting or style violations
✅ Your tests must pass - Sessions only complete when your test suite is green
✅ Your files stay organized - No mysterious root-level files cluttering your project
✅ Your workflows are enforced - Build processes, validation, and quality checks run automatically
✅ Everything is configurably logged - Complete visibility into what Claude did during each session
This isn't just wishful thinking—it's what conclaude delivers every single time.
While other tools try to bolt-on AI safety as an afterthought, conclaude was built from the ground up specifically for Claude Code workflows. Here's what sets it apart:
🎯 Purpose-Built for Claude Code: Native integration with Claude's lifecycle hooks—no hacks, no workarounds
⚡ Zero Configuration Friction: Simple YAML config that just works, powered by cosmiconfig
🛡️ Fail-Fast Protection: Catches problems immediately, not after damage is done
🔄 Extensible Hook System: Handle PreToolUse, PostToolUse, Stop, and more lifecycle events
📊 Session-Aware Logging: Every action is tracked with session context for complete auditability
Before conclaude:
Developer: "Claude, add user authentication to my app"
Claude: *writes beautiful auth code*
Developer: *tries to deploy*
CI/CD: ❌ 47 test failures, linting errors everywhere
Developer: *spends 2 hours fixing what should have been caught*
With conclaude:
Developer: "Claude, add user authentication to my app"
Claude: *writes beautiful auth code*
conclaude: ✅ All tests pass, linting clean
Developer: *deploys confidently*
The Problem:
You're reviewing Claude's work and find config.json, temp.js, and debug.log scattered in your project root. Your clean directory structure is now a mess.
The conclaude Solution:
# .conclaude.yaml
rules:
preventRootAdditions: true # No more mystery files!
Claude tries to create a root file → conclaude blocks it → Claude puts it in the right place.
The Vision: You're pair programming with Claude for hours, making incremental improvements. You want validation after every change, not just at the end.
The Setup:
# .conclaude.yaml
stop:
infinite: true
run: |
bun x tsc --noEmit
bun test --silent
infiniteMessage: "🛡️ Monitoring active - your code stays clean!"
Now every small change gets validated immediately. No surprises at the end of a long session.
# Install from crates.io
cargo install conclaude
# Clone and build from source
git clone https://github.com/conneroisu/conclaude.git
cd conclaude
cargo build --release
# The binary will be in target/release/conclaude
# Use the flake directly
nix run github:conneroisu/conclaude -- --help
Add conclaude as a flake input and include it in your development shell:
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
conclaude.url = "github:conneroisu/conclaude";
};
outputs = { self, nixpkgs, conclaude, ... }:
let
system = "x86_64-linux"; # or your system
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
packages = [
conclaude.packages.${system}.default
# your other packages...
];
shellHook = ''
echo "conclaude available in development environment"
conclaude --help
'';
};
};
}
Then enter the development shell:
nix develop
# Clone the repository
git clone https://github.com/conneroisu/conclaude.git
cd conclaude
# Build the project
cargo build
# Run tests
cargo test
# Install for development
cargo install --path .
Think of conclaude's configuration as your project's constitution—the fundamental rules that govern how Claude Code can interact with your codebase. It's designed to be simple enough to set up in minutes, yet powerful enough to handle complex enterprise workflows.
conclaude finds your rules automatically using cosmiconfig, looking for:
.conclaude.yaml - Your main configuration file (recommended).conclaude.yml - Alternative YAML extensionNo complex setup, no environment variables to manage. Just drop a .conclaude.yaml file in your project root and you're protected.
Here's what a real-world configuration looks like:
# .conclaude.yaml - Your project's guardrails
# Commands that MUST pass before any session ends
stop:
run: |
cargo fmt --check # Code formatting check
cargo clippy -- -D warnings # Linting with warnings as errors
cargo test # All tests must pass
cargo build # Successful compilation required
# File protection rules
rules:
preventRootAdditions: true # Keep project root clean
uneditableFiles: # Protect critical files
- "Cargo.toml" # Don't modify package manifest
- "Cargo.lock" # Lock file is sacred
- ".env*" # Secrets stay secret
- "target/**" # Build artifacts
What this accomplishes:
# Perfect for refactoring sessions or long pair-programming
stop:
run: |
cargo check --quiet # Fast compilation check
cargo test --quiet # Silent test execution
infinite: true # Validate after every change
infiniteMessage: "🔍 Watching your code quality..."
# Maximum security for production codebases
stop:
run: |
cargo audit # Security audit
cargo fmt --check # Strict formatting
cargo clippy -- -D warnings # All clippy warnings as errors
cargo test --all # Test all packages
cargo build --release # Release build
rules:
preventRootAdditions: true
uneditableFiles:
- "Cargo.toml"
- "Cargo.lock"
- ".env*"
- "target/**"
- ".github/workflows/**"
- "src/lib.rs" # Protect main library entry point
The complete configuration schema is defined as Rust structs with serde serialization. Key sections include:
Generate a complete JSON schema with: conclaude generate-schema
conclaude taps into Claude Code's lifecycle through strategic intervention points called "hooks." Think of hooks as security checkpoints in your development workflow—each one serves a specific purpose in keeping your codebase safe and consistent.
Fired the moment before Claude tries to use any tool
What it protects against:
package.json or .env filesReal example: Claude wants to create debug.log in your project root, but your preventRootAdditions rule blocks it. Claude adapts and creates logs/debug.log instead.
Fired immediately after Claude completes any tool operation
What it enables:
Real example: After Claude edits a file, PostToolUse logs exactly what changed, when, and in which session—giving you complete traceability.
Fired when Claude thinks the session is complete
This is where the magic happens. The Stop hook is your last line of defense and your quality assurance engine:
Real example: Claude finishes implementing a feature. Stop hook runs your tests, finds 3 failures, blocks completion. Claude sees the errors and fixes them automatically. Only then does the session complete successfully.
.conclaude.yaml)# Commands to run during Stop hook
stop:
run: |
cargo check
cargo test
cargo build
# Validation rules
rules:
# Block file creation at repository root
preventRootAdditions: true
# Files that cannot be edited (glob patterns)
uneditableFiles:
- "Cargo.toml"
- "Cargo.lock"
- ".env*"
- "target/**"
# Minimal checks for development
stop:
run: |
echo "Running development checks..."
cargo check
rules:
preventRootAdditions: false # Allow root edits during development
uneditableFiles:
- "Cargo.toml" # Still protect Cargo.toml
# Comprehensive validation for production
stop:
run: |
echo "Running production validation..."
cargo fmt --check
cargo clippy -- -D warnings
cargo test
cargo build --release
rules:
preventRootAdditions: true
uneditableFiles:
- "Cargo.toml"
- "Cargo.lock"
- ".env*"
- "target/**"
# Continuous monitoring with infinite mode
stop:
run: |
echo "Starting continuous monitoring..."
cargo check
cargo test
infinite: true
infiniteMessage: "Monitoring active - press Ctrl+C to stop"
rules:
preventRootAdditions: false # Allow file changes during development
uneditableFiles:
- "Cargo.toml"
conclaude is designed to be used as a hook handler in Claude Code. After global installation, use the conclaude init command to automatically configure Claude Code hooks:
# Initialize conclaude in your project
conclaude init
This creates:
.conclaude.yaml - Your project configuration.claude/settings.json - Claude Code hook configurationIf you prefer manual setup, configure hooks in your Claude Code settings:
{
"hooks": {
"PreToolUse": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "conclaude PreToolUse"
}
]
}
],
"PostToolUse": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "conclaude PostToolUse"
}
]
}
],
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "conclaude Stop"
}
]
}
]
}
}
# Create initial .conclaude.yaml configuration
conclaude init
# Force overwrite existing configuration
conclaude init --force
# Specify custom paths
conclaude init --config-path ./custom.yaml --claude-path ./.claude-custom
# Test Stop hook
echo '{"session_id":"test","transcript_path":"/tmp/test.jsonl","hook_event_name":"Stop","stop_hook_active":true}' | \
conclaude Stop
# Test PreToolUse hook
echo '{"session_id":"test","transcript_path":"/tmp/test.jsonl","hook_event_name":"PreToolUse","tool_name":"Write","tool_input":{"file_path":"test.txt"}}' | \
conclaude PreToolUse
# Get help
conclaude --help
conclaude Stop --help
The Stop hook executes commands from config.stop.run sequentially:
# Configuration
stop:
run: |
cargo check
cargo test
# Execution: If any command fails, the entire hook fails and blocks the session
✓ Command 1/2: cargo check
✗ Command 2/2: cargo test (exit code 1)
❌ Hook blocked: Command failed with exit code 1: cargo test
When preventRootAdditions: true, file-modifying tools are blocked at repo root:
# Blocked operations
Write → /repo/newfile.txt ❌ Blocked
Edit → /repo/config.json ❌ Blocked
# Allowed operations
Write → /repo/.gitignore ✓ Allowed (dotfile)
Write → /repo/src/component.rs ✓ Allowed (subdirectory)
Read → /repo/Cargo.toml ✓ Allowed (read-only)
# Format code
cargo fmt
# Run linting
cargo clippy
# Run tests
cargo test
# Build for distribution
cargo build --release
# Run hooks directly (development)
cargo run -- <hook-type>
# Use Nix development environment
nix develop -c lint # Run linting
nix develop -c tests # Run tests
├── src/
│ ├── main.rs # Main CLI entry point
│ ├── config.rs # Configuration loading and parsing
│ ├── types.rs # Rust type definitions for payloads
│ ├── hooks.rs # Hook handler implementations
│ ├── logger.rs # Logging configuration
│ ├── schema.rs # JSON Schema generation
│ ├── lib.rs # Library exports
│ └── default-config.yaml # Default configuration template
├── .conclaude.yaml # YAML configuration file
├── flake.nix # Nix development environment
├── Cargo.toml # Rust package manifest
└── README.md
Configuration is loaded using native Rust YAML parsing with automatic directory tree search:
.conclaude.yaml - Primary configuration file.conclaude.yml - Alternative YAML extensionThe search starts from the current directory and moves up the directory tree until a configuration file is found or the project root (indicated by package.json presence) is reached.
If no configuration file is found, conclaude will display the searched locations and suggest running conclaude init to generate a template configuration.
src/types.rssrc/hooks.rssrc/main.rsstdin JSON → read_payload_from_stdin() → validate_base_payload() → handler() → HookResult → exit code
.conclaude.yaml → serde_yaml parsing → ConclaudeConfig struct
config.stop.run → extract_bash_commands() → tokio::process::Command → sequential execution → fail fast
# Initialize configuration
conclaude init [--force] [--config-path <path>] [--claude-path <path>]
# Generate JSON Schema
conclaude generate-schema [--output <path>] [--validate]
# Hook handlers (called by Claude Code)
conclaude PreToolUse
conclaude PostToolUse
conclaude Stop
conclaude SessionStart
conclaude UserPromptSubmit
conclaude Notification
conclaude SubagentStop
conclaude PreCompact
# Visualize configuration
conclaude visualize [--rule <rule-name>] [--show-matches]
# Global options
--verbose # Enable debug logging
--disable-file-logging # Disable logging to temporary files
# Stop hook configuration
stop:
# Simple command format
run: |
cargo check
cargo test
cargo build
# Alternative: structured commands with custom messages
commands:
- run: "cargo test"
message: "Tests failed - fix failing tests before continuing"
- run: "cargo build"
message: "Build failed - fix compilation errors"
# Infinite mode - continue after successful validation
infinite: false
infiniteMessage: "Continue working on the task"
# Rounds mode - run for specific iterations
rounds: 3
# Content validation rules
grepRules:
- filePattern: "**/*.rs"
forbiddenPattern: "todo|fixme"
description: "No TODO or FIXME comments allowed"
# File and directory protection rules
rules:
# Prevent file creation at repository root
preventRootAdditions: true
# Files that cannot be edited (glob patterns)
uneditableFiles:
- "Cargo.toml"
- "Cargo.lock"
- ".env*"
- "target/**"
# Tool usage validation
toolUsageValidation:
- tool: "Write"
pattern: "**/*.rs"
action: "allow"
message: "Writing to Rust files is allowed"
- tool: "*"
pattern: ".env*"
action: "block"
message: "Environment files cannot be modified"
# Pre-tool-use hook configuration
preToolUse:
# Content validation before tool execution
grepRules:
- filePattern: "**/*.rs"
forbiddenPattern: "unsafe"
description: "Unsafe code blocks not allowed"
# Additional directories to protect from additions
preventAdditions:
- "docs/"
- "examples/"
# Git worktree integration
gitWorktree:
enabled: false
autoCreatePR: false
CONCLAUDE_LOG_LEVEL: Set logging level (debug, info, warn, error)CONCLAUDE_DISABLE_FILE_LOGGING: Disable logging to temporary filesContributions are welcome! Please feel free to submit a Pull Request.
git clone https://github.com/yourusername/conclaude.gitgit checkout -b feature-namecargo testcargo clippycargo fmtgit commit -am 'Add feature'git push origin feature-name# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Run specific test
cargo test test_name
# Run integration tests
cargo test --test integration
This project is licensed under the MIT License - see the LICENSE file for details.
Note: This is the Rust implementation of conclaude. For maximum performance and system integration, the Rust version is recommended over alternative implementations.