Clause Code is an interactive terminal coding agent built on the Claude Agent SDK. Claude can read your project, edit files, and run commands, and you approve every edit and shell command. All of it comes wrapped in holiday theming.
Key Features:
- ๐ ๏ธ A real coding agent: Claude reads, searches, edits, and runs code in your project folder
- ๐ You approve every file edit and shell command, with a diff or command preview first
- ๐งฑ File writes outside the project folder are always blocked
- ๐ฌ Claude Opus 5.5 by default, with Sonnet 5.5 and Haiku 5.5 a
/modelaway - ๐จ Streaming Markdown output with syntax highlighting and festive status messages
- โธ๏ธ Ctrl+C interrupts Claude mid-turn without quitting
- ๐ Command history with auto-completion
- ๐ Daily December coding challenges (advent calendar)
- Python 3.10 or higher
- An Anthropic API key
The Claude Agent SDK ships with its own Claude Code runtime, so there is nothing else to install.
git clone https://github.com/nothans/clause-code.git
cd clause-code
uv sync
uv run clause-codegit clone https://github.com/nothans/clause-code.git
cd clause-code
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install
pip install -e .
# Run
clause-codeOn first launch, Clause Code asks for:
- Your Anthropic API key (skipped if
ANTHROPIC_API_KEYis set) - Festive mode or minimal mode
Clause Code works in the folder you launch it from. Use --project for one session, or /project to switch and remember a folder for next time.
clause-code # work in the current folder
clause-code --project ~/code/sleigh # work in another folder
clause-code --model sonnet # use a different model for this sessionDescribe what you want. Claude explores the project, makes changes, and runs commands, announcing each step as it goes:
๐
> Add a --verbose flag to the CLI and a test for it
๐ Reading src/cli.py
๐ Checking it twice: def main
โ๏ธ Re-wrapping src/cli.py
โญโ Claude wants to edit src/cli.py โโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --- a/src/cli.py โ
โ +++ b/src/cli.py โ
โ + parser.add_argument("--verbose", action="store_true")โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Allow? [y]es / [a]lways for this session / [n]o: y
๐ Running pytest -q
...
โจ Sprinkled some magic dust on your solution! 18.2s ยท $0.0412
- Reads and searches inside the project run without asking.
- File edits and writes show a diff or preview first. Answer
ato allow that tool for the rest of the session, or turn on/autoaccept. - Shell commands always ask, and can't be approved for a whole session.
- Writes outside the project folder are blocked by a hook, even with
/autoaccepton. - Declining an action tells Claude to ask you how to proceed instead.
| Command | Description |
|---|---|
/help |
Show all available commands |
/setkey |
Configure or update your Anthropic API key |
/model |
Switch between Claude models (Opus, Sonnet, Haiku) |
/project |
Set your working folder (starts a new conversation) |
/autoaccept |
Apply file edits without asking (on/off) |
/santa |
Enable festive mode with maximum holiday cheer |
/grinch |
Switch to minimal mode (less festive) |
/advent |
Get daily coding challenges (December only) |
/clear |
Clear the screen and start a new conversation |
/exit or /quit |
Exit Clause Code |
- Opus 5.5 (Default): most capable, best for complex coding and agentic work
- Sonnet 5.5: fast and capable for everyday coding
- Haiku 5.5: fastest and cheapest, for quick questions
All three have a 1M token context window. Switch anytime with /model; the conversation carries over.
Two delightful themes:
- Santa Mode: full holiday cheer in status messages, tool announcements, and Claude's tone
- Grinch Mode: minimal, professional output for when you need focus
Watch Clause Code "think" with festive states:
- ๐ Sleighing...
- ๐ Jingling...
- โท๏ธ Snowboarding...
- ๐ Unwrapping...
- โ๏ธ Crystallizing...
- And more!
The status messages switch immediately; Claude's own tone follows from the next /clear.
Clause Code loads your project's CLAUDE.md and .claude/settings.json, so project conventions and permission rules you already use with Claude Code apply here too. Your personal ~/.claude settings are not loaded.
Daily coding challenges throughout December:
๐
> /advent
๐ Advent Calendar - December 5 ๐
โ๏ธ Day 5: Build a snowflake pattern generator using ASCII artClause Code stores its settings in ~/.clause-code/:
~/.clause-code/
โโโ config.json # Application settings
โโโ .api_key # API key, readable only by you (not encrypted)
โโโ history # Command history
You can configure via commands or by editing config.json:
{
"default_model": "opus",
"festive_mode": true,
"project_folder": "/path/to/your/project"
}project_folder is used when you launch without --project; if it's unset or missing, Clause Code uses the current folder.
export ANTHROPIC_API_KEY=sk-ant-your-key-hereA key in the environment takes precedence over the saved key and is never written to disk.
src/clause_code/
โโโ __init__.py
โโโ __main__.py # Entry point
โโโ _version.py # Version
โโโ cli.py # Chat loop, command routing, first-run setup
โโโ agent.py # Claude Agent SDK session (models, options, lifecycle)
โโโ permissions.py # Approval prompts and the project-folder write guard
โโโ render.py # Streaming output, tool announcements, errors
โโโ theme.py # Holiday theming system
โโโ commands/ # Slash command handlers
โ โโโ __init__.py
โ โโโ base.py
โ โโโ config.py
โโโ utils/
โโโ __init__.py
โโโ config.py # Configuration management
- Agent (agent.py): wraps
ClaudeSDKClient. It uses Claude Code's system prompt plus the Clause Code persona, and owns session lifecycle, model switching, and permission modes. - Permissions (permissions.py): the
can_use_toolcallback that shows previews and asks you, plus aPreToolUsehook that blocks writes outside the project. - Renderer (render.py): turns SDK messages into terminal output. Text streams as a live preview and is then rendered as Markdown. Model output is never parsed as Rich markup.
- CLI (cli.py): prompt loop, slash commands, and Ctrl+C handling that interrupts the current turn.
- Theme (theme.py): festive messages, tool labels, and ASCII art.
git clone https://github.com/nothans/clause-code.git
cd clause-code
uv sync --extra dev
# Run tests
uv run pytest
# Lint and format
uv run ruff check src tests
uv run ruff format src testsThe tests mock the SDK client with create_autospec(ClaudeSDKClient), so a call that doesn't match the real SDK's signature fails the test instead of passing silently. They make no network calls.
clause-code/
โโโ src/clause_code/ # Main package
โโโ tests/ # Test suite
โโโ docs/images/ # Screenshots
โโโ pyproject.toml # Project configuration
โโโ uv.lock # Locked dependency versions
โโโ README.md # This file
โโโ LICENSE # MIT License
Contributions are welcome! Here's how you can help:
- Report Bugs: open an issue with details
- Suggest Features: share your ideas for new commands or features
- Submit PRs: fork, create a feature branch, and submit a PR
- Add Festive Content: more holiday messages, ASCII art, or challenges
- Format and lint with ruff (
ruff format,ruff check) - Add tests for new features
- Update documentation for user-facing changes
- Keep the festive spirit alive!
- claude-agent-sdk: Claude Code as a library (agent loop, built-in tools, permissions, hooks)
- rich: terminal formatting, Markdown, and syntax highlighting
- prompt-toolkit: interactive input with history and auto-completion
- pydantic: configuration validation
- pytest / pytest-asyncio: testing
- ruff: linting and formatting
- โ/โ: navigate command history
- Tab: auto-complete slash commands
- Ctrl+C: interrupt Claude's current turn (or decline at an approval prompt)
- Ctrl+D: exit application
Check your API key:
clause-code
๐
> /setkeyOr set the environment variable:
export ANTHROPIC_API_KEY=sk-ant-your-key-hereThe runtime ships inside the claude-agent-sdk wheel. Reinstall it:
pip install --force-reinstall claude-agent-sdkMake sure your virtual environment is activated or use:
python -m clause_codeInterrupting a turn uses POSIX signal handling. On Windows, Ctrl+C during a turn exits Clause Code.
- Created by Hans Scharler
- Powered by Anthropic Claude and the Claude Agent SDK
- Built with Python, Rich, and holiday spirit
Happy Coding and Happy Holidays!
๐ ๐ โ๏ธ ๐ โญ ๐ ๐ท โ๏ธ
Made with โค๏ธ and festive cheer
