{"id":30523001,"url":"https://github.com/safx/ccr","last_synced_at":"2026-05-16T09:35:02.407Z","repository":{"id":310525842,"uuid":"1039438876","full_name":"safx/ccr","owner":"safx","description":"An ultra-fast status line hook for Claude Code written in Rust","archived":false,"fork":false,"pushed_at":"2026-01-29T14:50:14.000Z","size":268,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-30T03:51:21.756Z","etag":null,"topics":["claude-code","rust","statusline"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/safx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-17T08:22:14.000Z","updated_at":"2026-01-29T14:50:09.000Z","dependencies_parsed_at":"2025-08-18T18:27:12.108Z","dependency_job_id":null,"html_url":"https://github.com/safx/ccr","commit_stats":null,"previous_names":["safx/ccr"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/safx/ccr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safx%2Fccr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safx%2Fccr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safx%2Fccr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safx%2Fccr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/safx","download_url":"https://codeload.github.com/safx/ccr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safx%2Fccr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33096993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["claude-code","rust","statusline"],"created_at":"2025-08-26T19:44:22.010Z","updated_at":"2026-05-16T09:35:02.400Z","avatar_url":"https://github.com/safx.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ccr - Claude Code Usage StatusLine\n\nA statusline hook for Claude Code that displays usage costs and session information.\n\n## Installation\n\n### Homebrew (Recommended)\n\n```bash\nbrew tap safx/tap\nbrew install ccr\n```\n\n### Build from source\n\n```bash\n# Build release binary\ncargo build --release\n\n# Copy to your bin directory\ncp target/release/ccr ~/bin/\n```\n\n## Setup\n\nAdd to `~/.claude/settings.json`:\n\n```json\n{\n  \"statusLine\": {\n    \"type\": \"command\",\n    \"command\": \"ccr\"\n  }\n}\n```\n\nNote: If you installed via Homebrew, `ccr` will be in your PATH. If you built from source and installed to `~/bin/`, you may need to use the full path `$HOME/bin/ccr`.\n\n## What it displays\n\nThe statusline shows:\n- Current session cost\n- Hourly burn rate\n- Remaining time at current rate\n- Context usage percentage\n- Active session blocks\n- Code changes (lines added/removed)\n- Current directory \n- Git branch (when in a git repository)\n- Model name\n- Output style (when not default)\n\nExample output:\n```\nccr main 👤 Opus 4.1 [Learning] ⏰ 1h 18m left 💰 $63.87 today, $11.58 session, $62.35 block 🔥 $21.13/hr ⚖️ 70% (108,887 / 155,000) ✏️ +23 -17\n```\n\n## How it works\n\nccr reads Claude Code usage data from `~/.config/claude_code/projects/**/*.jsonl` files and:\n\n1. Parses JSONL entries containing API usage information\n2. Deduplicates entries using message_id:request_id pairs\n3. Groups activity into 5-hour session blocks\n4. Calculates costs based on token usage and model pricing\n5. Outputs formatted statusline string to stdout\n\n## Input format\n\nClaude Code sends JSON via stdin:\n\n```json\n{\n  \"session_id\": \"3680e2cb-6c42-4c66-8545-973e66227c1d\",\n  \"cwd\": \"/Users/someone/src/mydev/ccr\",\n  \"transcript_path\": \"/Users/someone/.claude/projects/-Users-someone-src-mydev-ccr/3680e2cb-6c42-4c66-8545-973e66227c1d.jsonl\",\n  \"model\": {\n    \"id\": \"claude-opus-4-1-20250805\",\n    \"display_name\": \"Opus 4.1\"\n  },\n  \"workspace\": {\n    \"current_dir\": \"/Users/someone/src/mydev/ccr\",\n    \"project_dir\": \"/Users/someone/src/mydev/ccr\"\n  },\n  \"version\": \"1.0.85\",\n  \"output_style\": {\n    \"name\": \"Standard\"\n  },\n  \"cost\": {\n    \"total_cost_usd\": 5.14,\n    \"total_duration_ms\": 1234567,\n    \"total_api_duration_ms\": 456789,\n    \"total_lines_added\": 23,\n    \"total_lines_removed\": 17\n  }\n}\n```\n\n## Profiling tools\n\nTwo binaries are included for performance analysis:\n\n```bash\n# Basic profiling\n./target/release/profile\n\n# Detailed breakdown\n./target/release/profile_deep\n```\n\n## Project structure\n\n```\nsrc/\n├── lib.rs                      # Library exports\n├── constants.rs                # Shared constants  \n├── error.rs                    # Error types and handling\n├── types/                      # Data structures and domain logic\n│   ├── mod.rs                  # Module exports\n│   ├── ids.rs                  # ID types (SessionId, MessageId, etc.)\n│   ├── input.rs                # Input data structures\n│   ├── pricing.rs              # Pricing models and calculations\n│   ├── session.rs              # Session blocks and snapshots\n│   ├── usage.rs                # Usage entry structures\n│   ├── burn_rate.rs            # Burn rate calculation (NewType)\n│   ├── context_tokens.rs       # Context token handling (NewType)\n│   ├── cost.rs                 # Cost calculation and formatting (NewType)\n│   └── remaining_time.rs       # Remaining time calculation (NewType)\n├── utils/                      # Utility functions\n│   ├── mod.rs                  # Module exports\n│   ├── data_loader.rs          # Parallel JSONL file loading\n│   ├── transcript_loader.rs    # Transcript file parsing\n│   ├── git.rs                  # Git branch detection\n│   └── paths.rs                # Claude Code path discovery\n└── bin/\n    ├── ccr.rs                  # Main statusline hook\n    ├── filter_stats.rs         # Statistics filtering tool\n    ├── profile.rs              # Performance profiling\n    ├── profile_deep.rs         # Detailed profiling\n    ├── profile_loader.rs       # Data loader profiling\n    ├── profile_micro.rs        # Micro-benchmarking tool\n    └── bench_sessionid.rs      # SessionId benchmarking\n```\n\n## Building from source\n\n```bash\n# Development\ncargo build\n\n# Release (with optimizations)\ncargo build --release\n\n# Run tests\ncargo test\n\n# Run with cargo-nextest (if installed)\ncargo nextest run\n```\n\n## Testing\n\n```bash\n# Run all tests\ncargo test\n\n# Run with cargo-nextest (recommended)\ncargo nextest run\n\n# Test with sample input\necho '{\"session_id\":\"test\",\"cwd\":\"/tmp\",\"transcript_path\":\"/dev/null\",\"model\":{\"display_name\":\"claude-3-5-sonnet-20241022\",\"max_output_tokens\":8192}}' | ./target/release/ccr\n```\n\n## Development History\n\n1. Started with [ccusage](https://github.com/ryoppippi/ccusage) by ryoppippi\n2. Converted ccusage to `other_langage/ccr_deno.ts` (standalone Deno TypeScript version)\n3. Developed this Rust version based on ccr_deno.ts\n4. Refactored to use NewType pattern and clean architecture principles\n\nThe core algorithms - session block identification, cost calculation, and deduplication logic - originate from the ccusage implementation.\n\n## Acknowledgments\n\nThis implementation is heavily based on [ccusage](https://github.com/ryoppippi/ccusage) by ryoppippi. I'm grateful for the well-designed original implementation and for making it open source. The clear architecture and algorithms in ccusage made this Rust port possible. Thank you!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsafx%2Fccr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsafx%2Fccr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsafx%2Fccr/lists"}