cc-statusline
CLAUDE.md642 starsChanged 16 months agoMITView on GitHub
cc-statusline is a TypeScript CLI tool that generates custom statuslines for Claude Code. It creates optimized bash scripts that display directory, git info, model name, usage costs, and session time in the terminal. The codebase follows a modular ESM TypeScript architecture: Key design patterns: - Feature flags determine which bash code blocks are included in generated scripts - All bash generation is template-based with conditional sections - Mock testing simulates Claude Code's JSON input for preview functionality Build System: Uses…
- Installs packages
The file
We split this CLAUDE.md into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 46
All bash generation is template-based with conditional sections
- Very specific: line 74
Use ESM imports with .js extensions (even for .ts files)
- Distinctive: line 76
Follow conventional commits format for commit messages
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
cc-statusline is a TypeScript CLI tool that generates custom statuslines for Claude Code. It creates optimized bash scripts that display directory, git info, model name, usage costs, and session time in the terminal.
Development Commands
# Install dependencies
npm install
# Build the project (required before testing)
npm run build
# Watch mode for development
npm run dev
# Test the CLI locally
./dist/index.js init --no-install
./dist/index.js preview ./test-statusline.sh
# Test as if installed globally
npx . init
# Test the generated statusline with mock data
./test_debug.sh
# Run installation tests
./test/test-installation.shArchitecture
The codebase follows a modular ESM TypeScript architecture:
- CLI Layer (
src/cli/): Commander.js-based CLI with interactive prompts using Inquirer - Generator Layer (
src/generators/): Creates optimized bash scripts based on user configuration - Feature Modules (
src/features/): Isolated implementations for git, usage tracking, and colors - Utility Layer (
src/utils/): Installation, validation, and testing utilities
Key design patterns:
- Feature flags determine which bash code blocks are included in generated scripts
- All bash generation is template-based with conditional sections
- Mock testing simulates Claude Code's JSON input for preview functionality
Key Implementation Details
Build System: Uses tsup for ESM bundling with Node 16+ target. The #!/usr/bin/env node shebang is automatically added during build.
Generated Scripts: The bash statuslines are self-contained with graceful fallbacks when dependencies (jq, git, ccusage) are missing. Scripts execute in <100ms with minimal resource usage.
Installation Flow:
- Collects user preferences via inquirer prompts
- Generates optimized bash script with only selected features
- Writes to
.claude/statusline.shwith execute permissions - Updates
.claude/settings.jsonto register the statusline command
Testing Approach: Preview command uses mock Claude Code JSON data to test statuslines before installation. Real testing requires manual verification with Claude Code running.
Critical Bug-Prone Areas
JSON Parsing in Bash: The bash-generator.ts file contains a fallback JSON parser for systems without jq. This uses complex grep/sed patterns with careful quote escaping. The quotes in the grep patterns must be escaped as \\" in the TypeScript template strings to generate valid bash code.
Quote Escaping in bash-generator.ts: Lines 100-105 contain grep patterns that require double escaping:
- TypeScript template literal needs
\\for a single backslash - Bash needs
\"for escaped quotes - Combined:
\\"\\${field}\\"to produce"${field}"in the final bash script
Important Conventions
- Use ESM imports with
.jsextensions (even for.tsfiles) - Maintain 2-space indentation without semicolons
- Follow conventional commits format for commit messages
- Generated bash scripts must be POSIX-compliant with fallbacks
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

