My Claude Code Setup

May 4, 2026 · View on GitHub

GitHub stars GitHub forks GitHub issues

May 4, 2026 — CLAUDE.md template updated. The CLAUDE.md template has been modernized with 3 new variants (CLAUDE-template-1.md, CLAUDE-template-2.md, CLAUDE-template-3.md) following official Anthropic best practices — including dual-memory architecture, progressive disclosure, and standalone behavioral rules. Existing users: use CLAUDE-migrate-to-new-template.md as an AI prompt to migrate your current CLAUDE.md to any of the new templates while preserving all your project-specific content. See Choosing a CLAUDE.md Template for details.

My Claude Code Setup

What This Repository Provides

  • Starter Settings for Claude Code projects with optimized configurations
  • Memory Bank System for context retention across chat sessions
  • Pre-configured Hooks, Skills, and Subagents for enhanced productivity
  • MCP Server Recommendations for extending Claude Code capabilities

Quick Navigation

What do you want to do?Jump to
Install & get startedGetting Started
Set up persistent memoryMemory Bank System
Add plugins to Claude CodePlugins
Connect external toolsMCP Servers
Run parallel AI sessionsGit Worktrees
Customize Claude's behaviorCustomization
Use Z.AI for higher quotasZ.AI Integration
Monitor costs and usageCosts & Usage
Look up settings/configConfiguration Reference

Getting Started

Prerequisites

RequirementNotes
Claude AI AccountPro ($20/mo), Max ($100/mo), or Max ($200/mo)
Node.js 18+Runtime environment
GitVersion control
ripgrep, fd, jqFast tools (macOS: brew install ripgrep fd jq)

Installation Options

Choose the approach that works best for you:

Option A: Clone Entire Repository (New Projects)

# 1. Clone this repository as your new project
git clone https://github.com/centminmod/my-claude-code-setup.git my-project
cd my-project

# 2. Remove template README files (create your own)
rm README.md README-v2.md README-v3.md README-v4.md

# 3. Reinitialize git for your own project (optional)
rm -rf .git
git init

# 4. Launch Claude Code and initialize
claude
# Then run: /init

Option B: Selective Copy (Existing Projects)

Copy only what you need into your existing project:

# Core files (recommended)
cp /path/to/my-claude-code-setup/CLAUDE.md your-project/
cp -r /path/to/my-claude-code-setup/.claude your-project/

# Or pick specific components:
cp -r /path/to/my-claude-code-setup/.claude/commands your-project/.claude/
cp -r /path/to/my-claude-code-setup/.claude/skills your-project/.claude/
cp -r /path/to/my-claude-code-setup/.claude/agents your-project/.claude/
cp -r /path/to/my-claude-code-setup/.claude/hooks your-project/.claude/

Option C: Download from GitHub

Browse the repository and download individual files:

  • CLAUDE.md - Memory bank main file (uses Template 3 format)
  • CLAUDE-template-1.md - Compact self-contained template
  • CLAUDE-template-2.md - Memory bank system template
  • CLAUDE-template-3.md - Progressive disclosure template
  • CLAUDE-migrate-to-new-template.md - Template migration guide
  • .claude/settings.json - Settings template
  • .claude/rules/core-rules.md - Behavioral rules (required by Template 3)
  • .claude/commands/ - Slash commands
  • .claude/skills/ - Skills
  • .claude/agents/ - Subagents

What Happens Next?

  1. Claude Code analyzes your codebase
  2. Memory bank files are populated based on your project
  3. You're ready to start coding with persistent context!

Optional Enhancements

  • VS Code Integration: Install Claude Code Extension
  • GitHub Setup: Configure Git for VS Code (guide)
  • Dev Container: Use the isolated dev environment for YOLO mode
  • Platform Docs: Add CLAUDE-cloudflare.md for Cloudflare/ClerkOS or CLAUDE-convex.md for Convex

Learning Resources


I want to set up the memory bank system

What is Memory Bank?

The Memory Bank System helps Claude Code remember context across chat sessions. Instead of starting fresh each time, Claude reads structured markdown files to understand your project's patterns, decisions, and current state.

Core Context Files

FileWhat it stores
CLAUDE.mdMain entry point with project overview and AI guidance
CLAUDE-activeContext.mdCurrent session state, goals, and progress
CLAUDE-patterns.mdEstablished code patterns and conventions
CLAUDE-decisions.mdArchitecture decisions and rationale (ADRs)
CLAUDE-troubleshooting.mdCommon issues and proven solutions
CLAUDE-config-variables.mdConfiguration variables reference
CLAUDE-temp.mdTemporary scratch pad (only read when referenced)

Token-Free Notes

HTML comments (<!-- -->) in CLAUDE.md are stripped from context at runtime and cost zero tokens. The templates use them for guidance notes — you can add your own without impacting Claude's context window.

Initial Setup

  1. Copy template files from this repository to your project root
  2. Run /init in Claude Code
  3. Claude analyzes your codebase and populates the memory bank

Updating Memory Bank

After completing significant work:

update memory bank

Claude Code will update all relevant CLAUDE-*.md files with your latest changes.

Example Output

> update memory bank

∴ Thinking…
  I'll update the memory bank files to reflect the v0.1.6 changes...

⏺ Summary: v0.1.6 Release Complete ✅

  Memory Bank Updates Complete:
  - CLAUDE-activeContext.md - v0.1.6 session context
  - CLAUDE-patterns.md - Added patterns 22-24
  - CLAUDE-decisions.md - Added ADR-017 & ADR-018
  - CLAUDE-troubleshooting.md - Added 4 new issue/fix entries

  Test Results: All 29 tests passing

See also: Customization for creating custom subagents that sync memory bank with code

Choosing a CLAUDE.md Template

This repo provides 3 modernized templates following official Anthropic best practices:

TemplateLinesBest For
CLAUDE-template-1.md~101Quick starts — compact, self-contained, all rules inline
CLAUDE-template-2.md~153Existing memory bank users — full workflow, dual-memory comparison
CLAUDE-template-3.md~105Teams — progressive disclosure, rules externalized to .claude/rules/

All templates include dual-memory architecture and progressive disclosure. The current CLAUDE.md uses Template 3 format.

Already have a CLAUDE.md? Use CLAUDE-migrate-to-new-template.md as a prompt — Claude Code will migrate your existing content to your chosen template while preserving all project-specific information.


I want to extend Claude Code with plugins

Official Anthropic Marketplace

Browse plugins at the official marketplace.

# Install a plugin
/plugin install plugin-name@claude-plugins-official

# Update marketplace
/plugin marketplace update claude-plugins-official
PluginWhat it doesInstall
code-simplifierSimplifies code for clarity and maintainability/plugin install code-simplifier
frontend-designCreates production-grade frontend interfaces/plugin install frontend-design@claude-code-plugins
feature-dev7-phase approach to building features/plugin install feature-dev@claude-code-plugins
ralph-wiggumIterative AI loops for development/plugin install ralph-wiggum@claude-code-plugins

Note: Ralph Wiggum has issues on some systems (#16398, #16389). Usage video

Third-Party Plugins

Safety Net - Catches destructive commands before execution:

/plugin marketplace add kenryu42/cc-marketplace
/plugin install safety-net@cc-marketplace

Z.AI Usage Query - Query Z.AI usage statistics:

/plugin marketplace add zai/zai-coding-plugins
/plugin install glm-plan-usage@zai-coding-plugins

Cloudflare Skills - Cloudflare platform development (Workers, Agents SDK):

/plugin marketplace add cloudflare/skills

See also: MCP Servers for connecting external tools


I want to connect external tools (MCP)

What is MCP?

MCP (Model Context Protocol) servers extend Claude Code by connecting to external tools, documentation, and services.

ServerWhat it doesInstall
Context7Look up docs for any libraryclaude mcp add --transport http context7 https://mcp.context7.com/mcp --header "CONTEXT7_API_KEY: YOUR_KEY" -s user
Cloudflare DocsCloudflare documentationclaude mcp add --transport sse cf-docs https://docs.mcp.cloudflare.com/sse -s user
Usage MetricsTrack Claude Code costsclaude mcp add --transport stdio metrics -s user -- uv run --directory /path/to/mcp-server metrics-server
Gemini CLIAccess Gemini modelsclaude mcp add gemini-cli /path/to/.venv/bin/python /path/to/mcp_server.py -s user -e GEMINI_API_KEY='KEY'
NotionNotion workspace integrationSee below

Installing Notion MCP

claude mcp add-json notionApi '{"type":"stdio","command":"npx","args":["-y","@notionhq/notion-mcp-server"],"env":{"OPENAPI_MCP_HEADERS":"{\"Authorization\": \"Bearer ntn_API_KEY\", \"Notion-Version\": \"2022-06-28\"}"}}' -s user

Chrome DevTools MCP (On-Demand)

Due to ~17K token overhead, install only when needed:

claude --mcp-config .claude/mcp/chrome-devtools.json

Create .claude/mcp/chrome-devtools.json:

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@latest"]
    }
  }
}

Verify Installation

claude mcp list
# context7: ✓ Connected
# cf-docs: ✓ Connected
# metrics: ✓ Connected

Example: Cost Tracking

The get_current_cost tool returns:

{
  "metric": "Total Cost Today",
  "formatted": "\$27.15",
  "unit": "currencyUSD"
}

See also: Plugins for the official plugin system


I want to run parallel AI coding sessions

Why Git Worktrees?

Git worktrees let you run multiple Claude Code sessions with complete code isolation. Each worktree has its own working directory while sharing Git history.

Benefits:

  • Run parallel AI sessions simultaneously
  • Each worktree has independent file state
  • Changes won't interfere between sessions
  • Perfect for experimental features or YOLO mode

Setup Shell Functions

macOS / Linux - Add to ~/.bashrc or ~/.zshrc:

# Claude Code worktree launcher
clx() {
    local branch_name
    if [ -z "\$1" ]; then
        branch_name="worktree-$(date +%Y%m%d-%H%M%S)"
    else
        branch_name="\$1"
    fi
    git worktree add "../$branch_name" -b "$branch_name" && \
    cd "../$branch_name" || return 1
    claude --model opusplan --permission-mode plan
}

# Codex CLI worktree launcher
cx() {
    local branch_name
    if [ -z "\$1" ]; then
        branch_name="worktree-$(date +%Y%m%d-%H%M%S)"
    else
        branch_name="\$1"
    fi
    git worktree add "../$branch_name" -b "$branch_name" && \
    cd "../$branch_name" || return 1
    codex -m gpt-5-codex --config model_reasoning_effort='xhigh'
}

Reload: source ~/.bashrc or source ~/.zshrc

Windows PowerShell

Add to PowerShell profile (notepad $PROFILE):

function clx {
    param([string]$BranchName)
    if (-not $BranchName) {
        $BranchName = "worktree-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
    }
    git worktree add "../$BranchName" -b $BranchName
    if ($LASTEXITCODE -eq 0) {
        Set-Location "../$BranchName"
        claude --model opusplan --permission-mode plan
    }
}

function cx {
    param([string]$BranchName)
    if (-not $BranchName) {
        $BranchName = "worktree-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
    }
    git worktree add "../$BranchName" -b $BranchName
    if ($LASTEXITCODE -eq 0) {
        Set-Location "../$BranchName"
        codex -m gpt-5-codex --config model_reasoning_effort='xhigh'
    }
}

Reload: . $PROFILE

Windows CMD Batch

Create clx.bat in a PATH directory:

@echo off
setlocal enabledelayedexpansion
if "%~1"=="" (
    for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /value') do set datetime=%%I
    set branch_name=worktree-!datetime:~0,8!-!datetime:~8,6!
) else (
    set branch_name=%~1
)
git worktree add "../%branch_name%" -b "%branch_name%"
if %errorlevel% equ 0 (
    cd "../%branch_name%"
    claude --model opusplan --permission-mode plan
)
endlocal

Create cx.bat similarly for Codex CLI.

Usage

# Named worktree
clx feature-auth
cx bugfix-123

# Auto-generated timestamp name
clx
cx

Managing Worktrees

git worktree list          # List all worktrees
git worktree remove ../name # Remove a worktree
git worktree prune         # Clean up stale references

Environment Setup

Each worktree needs its own dependencies:

  • Node.js: npm install or yarn
  • Python: pip install -r requirements.txt

The .worktreeinclude File

Specify which .gitignored files to copy to new worktrees:

# Environment files
.env
.env.local
.env.*

# Claude Code local settings
**/.claude/settings.local.json

Claude Desktop Worktree Location

  • Default: ~/.claude-worktrees
  • Configurable in Claude Desktop settings
  • Repository must be Git initialized

Local Ignores Without .gitignore

Use .git/info/exclude for local-only ignores:

.idea/
my-local-scripts/
FileScopeShared
.gitignoreTeamYes
.git/info/excludeLocalNo
~/.config/git/ignoreGlobalNo

See also: Z.AI + Worktrees for combining Z.AI with worktrees


I want to customize Claude's behavior

Custom Slash Commands

/anthropic Commands

CommandWhat it does
/apply-thinking-toEnhances prompts with Anthropic's extended thinking patterns
/convert-to-todowrite-tasklist-promptConverts prompts to parallel task execution (60-70% faster)
/update-memory-bankUpdates CLAUDE.md and memory bank files

/ccusage Commands

CommandWhat it does
/ccusage-dailyComprehensive usage cost analysis with daily breakdowns

/cleanup Commands

CommandWhat it does
/cleanup-contextMemory bank optimization (15-25% token reduction)

/documentation Commands

CommandWhat it does
/create-readme-sectionGenerates README sections with professional formatting
/create-release-noteCreates dual release notes (customer-facing + technical)

/security Commands

CommandWhat it does
/security-auditOWASP-based security audit
/check-best-practicesLanguage-specific best practices analysis
/secure-promptsDetects prompt injection attacks

Test prompts available at .claude/commands/security/test-examples/

/architecture Commands

CommandWhat it does
/explain-architecture-patternIdentifies and explains architectural patterns

/promptengineering Commands

CommandWhat it does
/convert-to-test-driven-promptTransforms requests into TDD-style prompts
/batch-operations-promptOptimizes for parallel file operations

/refactor Commands

CommandWhat it does
/refactor-codeCreates detailed refactoring plans with risk assessment

Custom Skills

Skills provide specialized capabilities. See official docs.

SkillWhat it does
claude-code-guide (built-in)Natively built-in subagent for Claude Code CLI features, hooks, MCP servers, settings, Agent SDK, and API usage
consult-zaiDual-AI consultation comparing z.ai GLM 4.7 and code-searcher responses
consult-codexDual-AI consultation comparing Codex GPT-5.2 and code-searcher responses
ai-image-creatorGenerate PNG images using AI (Gemini, FLUX.2, Riverflow, SeedDream, GPT-5, GPT-5.4 Image 2) with configurable aspect ratios and resolutions. Supports transparent backgrounds (-t), reference image editing (-r), image analysis/description (--analyze), cost tracking (--costs), prompt enhancement patterns, and composite banner generation for multi-size logo banners. Requires setup
session-metricsParse Claude Code JSONL logs into per-turn token/cost/cache breakdowns. Multi-format export (text/JSON/CSV/MD/HTML), 5-hour session blocks with 7/14/30-day counters, weekly roll-up with percentage deltas, session duration + burn rate, hour-of-day + weekday punchcard, and pluggable chart libraries via --chart-lib {highcharts,uplot,chartjs,none}. Instance-wide dashboard (--all-projects, v1.14.0+) aggregates every project under ~/.claude/projects/ with per-project HTML drilldowns. Stdlib-only Python, zero network at runtime. Also installable via /plugin install session-metrics@centminmod.

Custom Subagents

Subagents handle complex tasks autonomously with their own context window. See official docs.

AgentWhat it does
memory-bank-synchronizerKeeps memory bank in sync with codebase
code-searcherEfficient codebase search with optional CoD mode (80% fewer tokens)
get-current-datetimeAccurate Brisbane timezone (GMT+10) timestamps
ux-design-expertComprehensive UX/UI guidance with Tailwind CSS & Highcharts
zai-cliCLI wrapper for z.ai GLM 4.7 (used by consult-zai skill)
codex-cliCLI wrapper for Codex GPT-5.2 (used by consult-codex skill)

Hooks

Hooks run custom commands before/after tool execution.

Included Hook: STOP notification using Terminal-Notifier for macOS desktop notifications. Setup: Terminal-Notifier

See also: Configuration Reference for all settings options


I want to use Z.AI for higher quotas

What is Z.AI?

Z.AI's GLM Coding Plan provides cost-effective access to high-performance GLM models optimized for coding, with significantly higher quotas than standard Claude plans.

10% Discount: Use invite code WWB8IFLROM

Pricing & Plans

PlanPrompts/5hrsMonthly Costvs Claude
Lite~120~$33× Claude Pro quota
Pro~600Higher3× Claude Max 5x quota
Max~2,400Higher3× Claude Max 20x quota

Each prompt allows 15–20 model calls = billions of tokens monthly at ~1% of API pricing.

Privacy

  • Data Location: Singapore
  • Privacy Guarantee: Z.AI does not store any content you provide
  • Privacy Policy

Prerequisites

Setup Options

Option 1: Automated (macOS/Linux only)

curl -O "https://cdn.bigmodel.cn/install/claude_code_zai_env.sh" && bash ./claude_code_zai_env.sh

Option 2: Manual - Edit ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your-zai-api-key",
    "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
    "API_TIMEOUT_MS": "3000000"
  }
}

Use Z.AI without affecting your existing Claude Code setup.

macOS / Linux - Add to ~/.bashrc or ~/.zshrc:

zai() {
    export ANTHROPIC_AUTH_TOKEN="your-zai-api-key"
    export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
    export API_TIMEOUT_MS="3000000"
    claude "$@"
}
Windows PowerShell
function zai {
    $env:ANTHROPIC_AUTH_TOKEN = "your-zai-api-key"
    $env:ANTHROPIC_BASE_URL = "https://api.z.ai/api/anthropic"
    $env:API_TIMEOUT_MS = "3000000"
    claude $args
}
Windows CMD Batch

Create zai.bat:

@echo off
set ANTHROPIC_AUTH_TOKEN=your-zai-api-key
set ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
set API_TIMEOUT_MS=3000000
claude %*

Model Mapping

Claude ModelGLM Model
OpusGLM-4.7
SonnetGLM-4.7
HaikuGLM-4.5-Air

Customize mappings (optional) by adding to your shell function:

export ANTHROPIC_DEFAULT_OPUS_MODEL="GLM-4.7"
export ANTHROPIC_DEFAULT_SONNET_MODEL="GLM-4.5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="GLM-4.5-Air"
Windows PowerShell Custom Mapping
function zai {
    $env:ANTHROPIC_AUTH_TOKEN = "your-zai-api-key"
    $env:ANTHROPIC_BASE_URL = "https://api.z.ai/api/anthropic"
    $env:API_TIMEOUT_MS = "3000000"
    $env:ANTHROPIC_DEFAULT_OPUS_MODEL = "GLM-4.7"
    $env:ANTHROPIC_DEFAULT_SONNET_MODEL = "GLM-4.5"
    $env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "GLM-4.5-Air"
    claude $args
}
Windows CMD Custom Mapping
@echo off
set ANTHROPIC_AUTH_TOKEN=your-zai-api-key
set ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
set API_TIMEOUT_MS=3000000
set ANTHROPIC_DEFAULT_OPUS_MODEL=GLM-4.7
set ANTHROPIC_DEFAULT_SONNET_MODEL=GLM-4.5
set ANTHROPIC_DEFAULT_HAIKU_MODEL=GLM-4.5-Air
claude %*

Usage

zai                              # Launch Z.AI
zai --model sonnet               # Specific model
zai --model opus --permission-mode plan

Z.AI + Git Worktree Integration

Combine Z.AI with worktrees for isolated parallel sessions:

macOS / Linux:

zaix() {
    local branch_name
    if [ -z "\$1" ]; then
        branch_name="worktree-$(date +%Y%m%d-%H%M%S)"
    else
        branch_name="\$1"
    fi
    git worktree add "../$branch_name" -b "$branch_name" && \
    cd "../$branch_name" || return 1

    export ANTHROPIC_AUTH_TOKEN="your-zai-api-key"
    export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
    export API_TIMEOUT_MS="3000000"
    claude --model sonnet --permission-mode plan
}
Windows PowerShell Z.AI + Worktree
function zaix {
    param([string]$BranchName)
    if (-not $BranchName) {
        $BranchName = "worktree-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
    }
    git worktree add "../$BranchName" -b $BranchName
    if ($LASTEXITCODE -eq 0) {
        Set-Location "../$BranchName"
        $env:ANTHROPIC_AUTH_TOKEN = "your-zai-api-key"
        $env:ANTHROPIC_BASE_URL = "https://api.z.ai/api/anthropic"
        $env:API_TIMEOUT_MS = "3000000"
        claude --model sonnet --permission-mode plan
    }
}
Windows CMD Z.AI + Worktree

Create zaix.bat:

@echo off
setlocal enabledelayedexpansion
if "%~1"=="" (
    for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /value') do set datetime=%%I
    set branch_name=worktree-!datetime:~0,8!-!datetime:~8,6!
) else (
    set branch_name=%~1
)
git worktree add "../%branch_name%" -b "%branch_name%"
if %errorlevel% equ 0 (
    cd "../%branch_name%"
    set ANTHROPIC_AUTH_TOKEN=your-zai-api-key
    set ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
    set API_TIMEOUT_MS=3000000
    claude --model sonnet --permission-mode plan
)
endlocal

Usage:

zaix feature-auth  # Named worktree
zaix               # Auto-generated name

See also: Parallel Sessions for more worktree details

Claude Code GitHub Actions

Automate AI-powered workflows in your repository with @claude mentions.

Key capabilities:

  • Respond to @claude mentions in issues and pull requests
  • Create and modify code through pull requests
  • Follow project-specific guidelines from CLAUDE.md

Reference: Claude Code GitHub Actions Documentation

Z.AI Integration Example

Create .github/workflows/claude.yml:

name: Claude Code

on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]
  issues:
    types: [opened, assigned]
  pull_request_review:
    types: [submitted]

jobs:
  claude:
    if: |
      (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
      (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
      (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
      (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
      issues: write
      id-token: write
      actions: read
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5
        with:
          fetch-depth: 1

      - name: Run Claude Code
        id: claude
        uses: anthropics/claude-code-action@v1
        env:
          ANTHROPIC_BASE_URL: https://api.z.ai/api/anthropic
          API_TIMEOUT_MS: 3000000
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          claude_args: |
            --model claude-opus
            --max-turns 100
ComponentPurpose
ANTHROPIC_BASE_URLRoutes API calls through Z.AI endpoint
API_TIMEOUT_MSExtended timeout (50 minutes)
claude_argsUses claude-opus with up to 100 turns

Setup: Add ANTHROPIC_API_KEY secret in repository settings, create workflow file, then mention @claude in issues/PRs.


I want to monitor costs and usage

Claude Plan Rate Limits

From August 28, 2025, weekly limits apply (plus monthly 50x 5hr session limit):

PlanSonnet 4 (hrs/week)Opus 4 (hrs/week)
Pro40–80
Max ($100/mo)140–28015–35
Max ($200/mo)240–48024–40

Status Lines

Display real-time usage in Claude Code.

Add to ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statuslines/statusline.sh",
    "padding": 0
  }
}

Create ~/.claude/statuslines/statusline.sh:

#!/bin/bash
# Read JSON input from stdin
input=$(cat)

# Extract model and workspace values
MODEL_DISPLAY=$(echo "$input" | jq -r '.model.display_name')
CURRENT_DIR=$(echo "$input" | jq -r '.workspace.current_dir')

# Extract context window metrics
INPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_input_tokens')
OUTPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_output_tokens')
CONTEXT_SIZE=$(echo "$input" | jq -r '.context_window.context_window_size')

# Extract cost metrics
COST_USD=$(echo "$input" | jq -r '.cost.total_cost_usd')
LINES_ADDED=$(echo "$input" | jq -r '.cost.total_lines_added')
LINES_REMOVED=$(echo "$input" | jq -r '.cost.total_lines_removed')

# Extract percentage metrics
USED_PERCENTAGE=$(echo "$input" | jq -r '.context_window.used_percentage')
REMAINING_PERCENTAGE=$(echo "$input" | jq -r '.context_window.remaining_percentage')

# Format tokens as Xk
format_tokens() {
    local num="\$1"
    if [ "$num" -ge 1000 ]; then
        echo "$((num / 1000))k"
    else
        echo "$num"
    fi
}

# Generate progress bar for context usage
generate_progress_bar() {
    local percentage=\$1
    local bar_width=20
    local filled=$(awk "BEGIN {printf \"%.0f\", ($percentage / 100) * $bar_width}")
    local empty=$((bar_width - filled))
    local bar=""
    for ((i=0; i<filled; i++)); do bar+="█"; done
    for ((i=0; i<empty; i++)); do bar+="░"; done
    echo "$bar"
}

# Calculate total
TOTAL_TOKENS=$((INPUT_TOKENS + OUTPUT_TOKENS))

# Generate progress bar
PROGRESS_BAR=$(generate_progress_bar "$USED_PERCENTAGE")

# Show git branch if in a git repo
GIT_BRANCH=""
if git -C "$CURRENT_DIR" rev-parse --git-dir > /dev/null 2>&1; then
    BRANCH=$(git -C "$CURRENT_DIR" branch --show-current 2>/dev/null)
    if [ -n "$BRANCH" ]; then
        # Worktree detection
        GIT_DIR=$(git -C "$CURRENT_DIR" rev-parse --git-dir 2>/dev/null)
        WORKTREE=""
        if [[ "$GIT_DIR" == *".git/worktrees/"* ]] || [[ -f "$GIT_DIR/gitdir" ]]; then
            WORKTREE=" 🌳"
        fi
        # Ahead/behind detection
        AHEAD_BEHIND=""
        UPSTREAM=$(git -C "$CURRENT_DIR" rev-parse --abbrev-ref '@{u}' 2>/dev/null)
        if [ -n "$UPSTREAM" ]; then
            AHEAD=$(git -C "$CURRENT_DIR" rev-list --count '@{u}..HEAD' 2>/dev/null || echo 0)
            BEHIND=$(git -C "$CURRENT_DIR" rev-list --count 'HEAD..@{u}' 2>/dev/null || echo 0)
            if [ "$AHEAD" -gt 0 ] && [ "$BEHIND" -gt 0 ]; then
                AHEAD_BEHIND=" ↕${AHEAD}/${BEHIND}"
            elif [ "$AHEAD" -gt 0 ]; then
                AHEAD_BEHIND=" ↑${AHEAD}"
            elif [ "$BEHIND" -gt 0 ]; then
                AHEAD_BEHIND=" ↓${BEHIND}"
            fi
        fi
        GIT_BRANCH=" | 🌿 $BRANCH${WORKTREE}${AHEAD_BEHIND}"
    fi
fi

echo "[$MODEL_DISPLAY] 📁 ${CURRENT_DIR##*/}${GIT_BRANCH}
Context: [$PROGRESS_BAR] ${USED_PERCENTAGE}%
Cost: \$${COST_USD} | +${LINES_ADDED} -${LINES_REMOVED} lines"

Cost Tracking MCP

Install the Usage Metrics MCP:

claude mcp add --transport stdio metrics -s user -- uv run --directory /path/to/mcp-server metrics-server

Cost Analysis Command

Use /ccusage-daily for detailed cost analysis with daily breakdowns, model statistics, and recommendations.

Optimization Tips

  • Use Z.AI for 3× higher quotas at lower cost
  • Use CoD mode in code-searcher for 80% token reduction
  • Use git worktrees for parallel sessions without duplicating quota
  • Monitor status lines to track real-time usage

See also: Z.AI for higher quota options


Configuration Reference

Settings Scopes

ScopeLocationWho it affects
ManagedSystem directoriesAll users (IT-controlled)
User~/.claude/settings.jsonYou (all projects)
Project.claude/settings.jsonAll collaborators
Local.claude/settings.local.jsonYou (this project only)

Precedence: Enterprise > CLI args > Local > Project > User

settings.json Options

KeyWhat it doesExample
apiKeyHelperScript to generate auth/bin/generate_key.sh
cleanupPeriodDaysDays to keep transcripts20
envEnvironment variables{"FOO": "bar"}
includeCoAuthoredByAdd Claude byline to commitsfalse

Permission Settings

KeyWhat it doesExample
allowAllowed tool rules["Bash(git diff:*)"]
denyDenied tool rules["WebFetch"]
additionalDirectoriesExtra working dirs["../docs/"]
defaultModeDefault permission mode"acceptEdits"

Environment Variables

VariablePurpose
ANTHROPIC_API_KEYAPI key for Claude SDK
ANTHROPIC_AUTH_TOKENCustom auth header
ANTHROPIC_BASE_URLCustom API endpoint
ANTHROPIC_MODELCustom model name
BASH_DEFAULT_TIMEOUT_MSDefault bash timeout
CLAUDE_CODE_MAX_OUTPUT_TOKENSMax output tokens
CLAUDE_CODE_USE_BEDROCKUse Amazon Bedrock
CLAUDE_CODE_USE_VERTEXUse Google Vertex AI
DISABLE_AUTOUPDATERDisable updates
DISABLE_TELEMETRYOpt out of telemetry
MCP_TIMEOUTMCP startup timeout
MCP_TOOL_TIMEOUTMCP tool timeout
MAX_MCP_OUTPUT_TOKENSMax MCP tokens (default: 25000)

File Locations

FilemacOS/LinuxWindows
User settings~/.claude/settings.json%USERPROFILE%\.claude\settings.json
Project settings.claude/settings.json.claude\settings.json
Local settings.claude/settings.local.json.claude\settings.local.json

Tools Available to Claude

ToolWhat it doesPermission
AgentRuns sub-agentsNo
BashShell commandsYes
EditFile editsYes
GlobFind files by patternNo
GrepSearch file contentsNo
LSList filesNo
MultiEditMultiple atomic editsYes
NotebookEditJupyter cell editsYes
NotebookReadRead Jupyter notebooksNo
ReadRead filesNo
TodoRead/TodoWriteTask managementNo
WebFetchFetch URLsYes
WebSearchWeb searchesYes
WriteCreate/overwrite filesYes

Config Commands

claude config list              # List settings
claude config get <key>         # Get setting
claude config set <key> <value> # Set setting
claude config set -g <key> <value> # Global setting

Resources

Official Documentation

YouTube Guides

Other Resources


Star History

Star History Chart


Stats

Alt