Skip to content

iamhenry/catcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Catcode 🐱

A sentiment-aware ASCII cat companion for Claude Code's statusline that generates dynamic motivational phrases.

catcode.mov

What It Does

Catcode analyzes your conversation with Claude and displays a cute ASCII cat with contextual phrases in your Claude Code statusline:

(=^.^=) | Stay focused today
(=o.o=) | Deep thinking mode  
(=-.=) | Progress through struggle

The cat faces and phrases are dynamically generated by Claude's Haiku model based on the sentiment of your latest message - nothing is hardcoded!

Features

  • Dual Mode Operation: Works as both a standalone console tool and Claude Code statusline integration
  • Dynamic Generation: Cat ASCII and motivational phrases are generated live by Claude Haiku model
  • Sentiment Analysis: Responds appropriately to positive, negative, and neutral messages
  • Smart Caching: UUID-based caching prevents API spam during statusline updates
  • Fast Performance: Sub-second cached responses suitable for ~300ms statusline updates

Requirements

  • Node.js 18+
  • Claude Code installed: npm install -g @anthropic-ai/claude-code
  • Authenticated Claude CLI: claude doctor

Quick Setup

  1. Clone and setup:

    git clone <this-repo>
    cd catcode
    chmod +x catcode.sh
  2. Test console mode:

    ./catcode.sh "I'm feeling great today!"
    # Output: (=^.^=) | Celebrate small victories
  3. Configure statusline in ~/.claude/settings.json:

    {
      "statusLine": {
        "type": "command", 
        "command": "/path/to/catcode/catcode.sh",
        "padding": 0
      }
    }

Usage Examples

Console Mode:

# Direct argument
./catcode.sh "This is frustrating"
# Output: (=-.=) | Patience builds strength

# Via stdin  
echo "Working on the project" | ./catcode.sh
# Output: (=o.o=) | Steady progress counts

Statusline Mode: When configured in Claude Code settings, catcode automatically:

  • Receives session JSON via stdin
  • Parses the transcript file to find your latest message
  • Generates contextual cat + phrase based on sentiment
  • Updates your statusline with motivational companion

How It Works

  1. Input Processing: Detects JSON (statusline mode) vs plain text (console mode)
  2. Message Extraction: For statusline mode, parses Claude Code JSONL transcript to get latest user message
  3. Sentiment Analysis: Uses Claude Haiku to classify sentiment (positive/negative/neutral)
  4. Dynamic Generation: Prompts Claude to generate appropriate cat ASCII + 3-5 word motivational phrase
  5. Caching: Stores results by message UUID to avoid redundant API calls

Project Status

PRODUCTION READY - Full dual-mode operation implemented
Phase 1 COMPLETE - Console prototype with dynamic generation
Phase 2 COMPLETE - Statusline integration with real JSONL parsing

See roadmap.md for detailed development progress.

Technical Details

  • Model: claude-3-5-haiku-20241022 for fast, cost-effective generation
  • Cache Location: ~/.cache/catcode/ (respects XDG_CACHE_HOME)
  • Response Format: (<cat-ascii>) | <motivational-phrase>
  • Update Frequency: Optimized for Claude Code's ~300ms statusline refresh rate

Troubleshooting

  • No output: Check claude doctor and model availability
  • Wrong format: Verify jq is installed for JSON parsing
  • Slow responses: Check cache directory permissions
  • API errors: Ensure Claude CLI is authenticated

A fun little project demonstrating Claude Code's statusline feature with headless API calls and transcript parsing.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages