Skip to content

nothans/clause-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ„ Clause Code

A festive AI coding assistant that brings holiday cheer to your terminal

Python 3.10+ License: MIT Anthropic SDK Code style: black


🎁 What is Clause Code?

Clause Code is an interactive terminal-based AI coding assistant powered by Anthropic's Claude. It combines powerful AI capabilities with delightful holiday theming to make your coding sessions more enjoyable and productive.

Key Features:

  • πŸ’¬ Interactive chat interface with Claude's latest models (Sonnet 4.5, Haiku 4.5, Opus 4.1)
  • 🎨 Beautiful terminal UI with syntax highlighting and festive animations
  • πŸ“ Automatic code extraction and file writing
  • πŸŽ„ Holiday-themed status messages and ASCII art
  • πŸ“š Command history with auto-completion
  • πŸŽ… Daily December coding challenges (advent calendar)
  • βš™οΈ Flexible configuration with multiple Claude models

πŸ“Έ Screenshot

Clause Code in action

Clause Code's festive terminal interface with Claude Sonnet 4.5

πŸš€ Quick Start

Prerequisites

Installation

Option 1: Using uv (Recommended)

git clone https://github.com/yourusername/clause-code.git
cd clause-code
uv sync
uv run clause-code

Option 2: Using pip

git clone https://github.com/yourusername/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-code

First Run Setup

On first launch, Clause Code will guide you through a quick setup:

  1. Enter your Anthropic API key (or set ANTHROPIC_API_KEY environment variable)
  2. Choose your preferred Claude model
  3. Set your project folder (optional)
  4. Select festive theme (Santa mode or Grinch mode)

You're ready to code with holiday cheer!

πŸ“– Usage

Basic Chat

Simply type your questions or coding requests:

πŸŽ„ You: Help me write a Python function to calculate fibonacci numbers

πŸŽ… Sleighing...

Here's a festive fibonacci implementation...
[Generated code with syntax highlighting]

Automatic File Writing

Clause Code automatically extracts and writes files from Claude's responses:

πŸŽ„ You: Create a new file hello.py with a hello world function

πŸŽ„ Jingling...

**File: hello.py**
[Code is automatically written to your project folder]

Slash Commands

Command Description
/help Show all available commands
/setkey Configure or update your Anthropic API key
/model Switch between Claude models (Sonnet, Haiku, Opus)
/project Set your working directory
/santa Enable festive mode with maximum holiday cheer
/grinch Switch to minimal mode (less festive)
/advent Get daily coding challenges (December only)
/clear Clear conversation history and screen
/exit or /quit Exit Clause Code

🎨 Features in Detail

Multiple Claude Models

Choose the right model for your task:

  • Sonnet 4.5 (Default) - Best for coding, balanced performance and capability
  • Haiku 4.5 - Fastest responses for quick questions
  • Opus 4.1 - Most capable for complex reasoning tasks

Switch models anytime with /model

Festive Theming

Two delightful themes:

  • Santa Mode - Full holiday cheer with festive messages and animations
  • Grinch Mode - Minimal, professional output for when you need focus

Watch Clause Code "think" with festive states:

  • πŸŽ… Sleighing...
  • πŸŽ„ Jingling...
  • ⛷️ Snowboarding...
  • 🎁 Unwrapping...
  • ❄️ Crystallizing...
  • And more!

Advent Calendar

Daily coding challenges throughout December:

πŸŽ„ You: /advent

πŸŽ… December 5th Challenge: Binary Tree Decorations
[Fun coding challenge with holiday twist]

Smart File Management

Clause Code automatically:

  • Extracts code blocks marked with file paths
  • Creates files in your project directory
  • Preserves file structure and formatting
  • Highlights written files in the output

βš™οΈ Configuration

Clause Code stores configuration in ~/.clause-code/:

~/.clause-code/
β”œβ”€β”€ config.json      # Application settings
β”œβ”€β”€ .api_key         # Encrypted API key
└── history          # Command history

Configuration Options

You can configure via commands or by editing config.json:

{
  "model": "claude-sonnet-4-5-20250929",
  "theme": "festive",
  "project_folder": "/path/to/your/project",
  "max_tokens": 64000
}

Environment Variables

Set your API key via environment variable:

export ANTHROPIC_API_KEY=sk-ant-your-key-here

πŸ—οΈ Architecture

src/clause_code/
β”œβ”€β”€ __init__.py
β”œβ”€β”€ __main__.py         # Entry point
β”œβ”€β”€ cli.py              # Main CLI application
β”œβ”€β”€ agent.py            # Claude SDK integration
β”œβ”€β”€ theme.py            # Holiday theming system
β”œβ”€β”€ commands/           # Slash command handlers
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ base.py
β”‚   └── config.py
└── utils/              # Utilities
    β”œβ”€β”€ __init__.py
    β”œβ”€β”€ config.py       # Configuration management
    └── file_writer.py  # File extraction & writing

Key Components

  • CLI (cli.py) - Async chat loop, command routing, first-run setup
  • Agent (agent.py) - Claude API integration, streaming responses, conversation history
  • Theme (theme.py) - Festive messages, ASCII art, status animations
  • Commands (commands/) - Slash command implementations
  • Utils (utils/) - Configuration management, file operations

πŸ§ͺ Development

Setup Development Environment

# Clone and install with dev dependencies
git clone https://github.com/yourusername/clause-code.git
cd clause-code
uv sync --extra dev

# Run tests
uv run pytest

# Format code
uv run black src/
uv run ruff check src/

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=clause_code

# Run specific test file
pytest tests/test_agent.py

Project Structure

clause-code/
β”œβ”€β”€ src/clause_code/     # Main package
β”œβ”€β”€ tests/               # Test suite
β”œβ”€β”€ demo_project/        # Example projects
β”œβ”€β”€ pyproject.toml       # Project configuration
β”œβ”€β”€ README.md            # This file
β”œβ”€β”€ PLAN.md              # Technical plan
β”œβ”€β”€ QUICKSTART.md        # Quick start guide
└── LICENSE              # MIT License

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Report Bugs - Open an issue with details
  2. Suggest Features - Share your ideas for new commands or features
  3. Submit PRs - Fork, create a feature branch, and submit a PR
  4. Add Festive Content - More holiday messages, ASCII art, or challenges

Contribution Guidelines

  • Follow PEP 8 style guidelines (enforced by Black)
  • Add tests for new features
  • Update documentation for user-facing changes
  • Keep the festive spirit alive!

πŸ“¦ Dependencies

Core Dependencies

  • anthropic (>=0.72.0) - Official Anthropic SDK
  • rich (>=13.7.0) - Beautiful terminal formatting and syntax highlighting
  • prompt-toolkit (>=3.0.43) - Interactive CLI with history and auto-completion
  • click (>=8.1.7) - Command-line interface creation
  • pydantic (>=2.5.0) - Configuration validation
  • python-dotenv (>=1.0.0) - Environment variable management
  • aiofiles (>=23.2.1) - Async file operations

Development Dependencies

  • pytest (>=7.4.0) - Testing framework
  • pytest-asyncio (>=0.21.0) - Async test support
  • black (>=23.0.0) - Code formatting
  • ruff (>=0.1.0) - Fast linting

🎯 Use Cases

Code Generation

Generate functions, classes, and complete modules with natural language requests.

Code Review

Get instant feedback on code quality, potential bugs, and improvement suggestions.

Debugging

Paste error messages and get detailed explanations with suggested fixes.

Learning

Ask questions about programming concepts, libraries, and best practices.

Refactoring

Request code improvements, optimization, and modernization.

Documentation

Generate docstrings, comments, and README files.

πŸ“‹ Keyboard Shortcuts

  • ↑/↓ - Navigate command history
  • Tab - Auto-complete slash commands
  • Ctrl+C - Cancel current operation
  • Ctrl+D - Exit application

❓ Troubleshooting

"API key not found"

Make sure you've set your API key:

clause-code
πŸŽ„ You: /setkey

Or set the environment variable:

export ANTHROPIC_API_KEY=sk-ant-your-key-here

"Module not found"

Ensure you've installed in editable mode:

pip install -e .

"Command not found: clause-code"

Make sure your virtual environment is activated or use:

python -m clause_code

πŸŽ… Credits


Happy Coding and Happy Holidays!

πŸŽ… πŸŽ„ ❄️ 🎁 ⭐ πŸ”” πŸ›· β˜ƒοΈ

Made with ❀️ and festive cheer

Report Bug Β· Request Feature Β· Documentation

About

A Chritmas themed AI coding terminal app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages