### Install Claudeline using Go Source: https://github.com/fredrikaverpil/claudeline/blob/main/commands/setup.md If the binary download fails or is not supported, you can fall back to using 'go install'. This requires Go to be installed and $GOPATH/bin to be in your $PATH. ```bash go install github.com/fredrikaverpil/claudeline@latest ``` -------------------------------- ### NewerAvailable Usage Example Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/update.md Examples of comparing different version strings for update availability. ```go // With v prefix newer := update.NewerAvailable("v1.2.3", "v1.2.4") // true newer := update.NewerAvailable("v1.2.5", "v1.2.4") // false // Without v prefix newer := update.NewerAvailable("1.2.3", "1.3.0") // true // Unparseable versions newer := update.NewerAvailable("(devel)", "v1.2.3") // false newer := update.NewerAvailable("v1.2.3", "1.2") // false (incomplete) ``` -------------------------------- ### Fetch Usage Example Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/update.md Example of checking for updates using the Fetch function. ```go ctx := context.Background() resp, err := update.Fetch(ctx, "v1.2.3", "/tmp/claudeline/update.json") if err != nil { println("Error checking for updates:", err) return } if resp != nil { println("Update available:", resp.TagName) } else { println("Already on latest version") } ``` -------------------------------- ### ReadResponse Usage Example Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/update.md Example of reading a release response from a local file path. ```go release, err := update.ReadResponse("/tmp/claudeline/update.json") if err != nil { panic(err) } if release.TagName != "" { println("Latest release:", release.TagName) } ``` -------------------------------- ### Fetch usage example Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/status.md Example of fetching service status with caching, handling operational and disruption states. ```go ctx := context.Background() resp, err := status.Fetch(ctx, "/tmp/claudeline/status.json") if err != nil { println("Error fetching status:", err) return } // resp is nil when service is operational if resp != nil { println("Service status:", resp.Status.Indicator) println("Description:", resp.Status.Description) } ``` -------------------------------- ### Configure Multiple Profiles Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Example of maintaining separate settings files for different profiles. ```bash # Default profile (~/.claude) ~/.claude/settings.json: { "statusLine": { "type": "command", "command": "claudeline" } } # Work profile (~/.claude-work) ~/.claude-work/settings.json: { "statusLine": { "type": "command", "command": "claudeline -cwd -git-branch" } } ``` -------------------------------- ### FetchAsync usage example Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/status.md Example of using FetchAsync to retrieve status concurrently while performing other work. ```go var wg sync.WaitGroup var resp *status.Response status.FetchAsync(ctx, cachePath, &wg, &resp) // Do other work... wg.Wait() // Block until fetch completes if resp != nil { println("Service disruption:", resp.Status.Indicator) } ``` -------------------------------- ### Cost usage example Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Demonstrates formatting a float cost value into a currency string. ```go cost := render.Cost(1.23456) // Output: "$1.23" ``` -------------------------------- ### FetchAsync Usage Example Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/update.md Example of performing an asynchronous update check using a WaitGroup. ```go var wg sync.WaitGroup var resp *update.Response update.FetchAsync(ctx, "v1.2.3", cachePath, &wg, &resp) // Do other work... wg.Wait() // Block until check completes if resp != nil { println("Update available:", resp.TagName) } ``` -------------------------------- ### ReadResponse usage example Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/status.md Example of reading a status response from a local JSON file. ```go status, err := status.ReadResponse("/tmp/claudeline/status.json") if err != nil { panic(err) } if status.Status.Indicator != "none" { println("Service disruption:", status.Status.Description) } ``` -------------------------------- ### QuotaSubBar usage example Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Demonstrates rendering a quota sub-bar with percentage, label, and reset time. ```go subBar := render.QuotaSubBar(45, "sonnet", "12:30") // Output: "▓░░░░ 45% sonnet (12:30)" ``` -------------------------------- ### Download and Install Claudeline Binary Source: https://github.com/fredrikaverpil/claudeline/blob/main/commands/setup.md Download the latest pre-built Claudeline binary from GitHub releases and install it to the specified target directory. Ensure the binary is executable. ```bash mkdir -p curl -fsSL "https://github.com/fredrikaverpil/claudeline/releases/latest/download/claudeline_${OS}_${ARCH}.tar.gz" | tar -xz -C claudeline chmod +x /claudeline ``` -------------------------------- ### Install via Claude Code plugin Source: https://github.com/fredrikaverpil/claudeline/blob/main/CLAUDE.md Commands to add and install the plugin directly within the Claude Code interface. ```text /plugin marketplace add fredrikaverpil/claudeline /plugin install claudeline@claudeline ``` -------------------------------- ### Configure status line with flags Source: https://github.com/fredrikaverpil/claudeline/blob/main/CLAUDE.md Example configuration enabling working directory and git branch display via command flags. ```json { "statusLine": { "type": "command", "command": "claudeline -cwd -git-branch" } } ``` -------------------------------- ### ExtraUsage usage example Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Demonstrates generating a usage string that applies red coloring when 80% of the limit is reached. ```go extra := render.ExtraUsage(80, 100) // Output: "\033[31m$80/$100\033[0m" (red if >= 80% used) ``` -------------------------------- ### UpdateIndicator usage examples Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Demonstrates generating an update indicator with a version tag and handling empty input. ```go indicator := render.UpdateIndicator("v1.2.4") // Output: "\033]8;;https://github.com/fredrikaverpil/claudeline/releases/tag/v1.2.4\a\033[32m↑\033[0m\033]8;;\a" indicator := render.UpdateIndicator("") // Output: "" ``` -------------------------------- ### Identify Cache File Paths Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Example paths for cache files showing default and custom profile suffixes. ```text /tmp/claudeline/usage.json (default profile) /tmp/claudeline/usage-a1b2c3d4.json (custom profile, hash-based suffix) ``` -------------------------------- ### Branch Function Usage Examples Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/git.md Demonstrates retrieving branch names for various repository states including standard, detached HEAD, non-git directories, and worktrees. ```go ctx := context.Background() // Standard repository branch := git.Branch(ctx, "/workspace/home/project") // Returns: "main" // Detached HEAD branch := git.Branch(ctx, "/path/to/detached") // Returns: "" // Not a git repository branch := git.Branch(ctx, "/tmp") // Returns: "" // Worktree branch := git.Branch(ctx, "/path/to/worktree") // Returns: "feature/my-feature" (branch associated with worktree) ``` -------------------------------- ### Example Cache File Paths Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/architecture.md Demonstrates how the paths package uses hash-based suffixes to prevent collisions between different Claude Code profiles. ```text /tmp/claudeline/usage.json (default profile) /tmp/claudeline/usage-a1b2c3d4.json (work profile) ``` -------------------------------- ### Example usage of Parse function Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/stdin.md Demonstrates reading from os.Stdin and parsing the input into the Data structure. ```go package main import ( "os" "io" "github.com/fredrikaverpil/claudeline/internal/stdin" ) func main() { // Read stdin JSON from Claude Code input, _ := io.ReadAll(os.Stdin) // Parse into structured data data, err := stdin.Parse(input) if err != nil { panic(err) } println(data.Model.DisplayName) println(*data.ContextWindow.UsedPercentage) } ``` -------------------------------- ### Verify Claudeline Binary Source: https://github.com/fredrikaverpil/claudeline/blob/main/commands/setup.md After installation, verify that the claudeline binary is available and executable by checking its version. ```bash /claudeline -version ``` -------------------------------- ### Detect API Provider Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Example usage of the Provider function to determine the active authentication method. ```go package main import "github.com/fredrikaverpil/claudeline/internal/creds" func main() { provider := creds.Provider() if provider != "" { println("Using provider:", provider) } else { println("Using subscription mode") } } ``` -------------------------------- ### Read OAuth Credentials Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Example usage of the Read function to retrieve credentials from the Keychain or local file system. ```go ctx := context.Background() cred, err := creds.Read(ctx, "", "Claude Code-credentials") if err != nil { log.Fatal("Failed to read credentials:", err) } println(cred.ClaudeAiOauth.SubscriptionType) ``` -------------------------------- ### Check for Third-Party Provider Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Example usage of IsThirdPartyProvider to identify if the current provider uses external cloud infrastructure. ```go provider := creds.Provider() if creds.IsThirdPartyProvider(provider) { println("Using cloud provider infrastructure") // status.claude.com not relevant for third-party providers } ``` -------------------------------- ### Get Default Configuration Directory Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/paths.md Retrieves the default Claude Code configuration directory path. Panics if the user home directory cannot be determined. ```go func DefaultConfigDir() string ``` ```go configDir := paths.DefaultConfigDir() // Returns: "/home/user/.claude" (on Linux/Mac) // Returns: "C:\Users\user\.claude" (on Windows) ``` -------------------------------- ### Generate Keychain Service Name Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Example usage of KeychainServiceName to generate a service name, including profile-specific hash suffixes. ```go // Default profile name := creds.KeychainServiceName("") // Returns: "Claude Code-credentials" // Custom profile name := creds.KeychainServiceName("/home/user/.claude-work") // Returns: "Claude Code-credentials-a1b2c3d4" (with hash suffix) ``` -------------------------------- ### Debug Log Output Format Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/errors.md Example of the log format generated in /tmp/claudeline/debug.log when the -debug flag is enabled. ```text 2026-07-12 10:15:23 claudeline: usage: fetching 2026-07-12 10:15:24 claudeline: credentials: parse credentials file: json: cannot unmarshal 2026-07-12 10:15:24 claudeline: unknown subscription type: subscription_type="premium" 2026-07-12 10:15:25 claudeline: status: fetch status API: execute request: context deadline exceeded ``` -------------------------------- ### GET https://api.github.com/repos/fredrikaverpil/claudeline/releases/latest Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/update.md Retrieves the latest release information for the claudeline repository from GitHub. ```APIDOC ## GET https://api.github.com/repos/fredrikaverpil/claudeline/releases/latest ### Description Retrieves the latest release information for the claudeline repository from the GitHub API. ### Method GET ### Endpoint https://api.github.com/repos/fredrikaverpil/claudeline/releases/latest ### Headers - **Accept**: application/vnd.github+json - **User-Agent**: claudeline ### Authentication None required. This is a public GitHub API endpoint. ### Rate Limiting - **Unauthenticated**: 60 requests per hour per IP. - Rate limit headers are included in the response. ``` -------------------------------- ### Get Cache Directory Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/paths.md Returns the platform-specific base directory for claudeline cache and log files. ```go func CacheDir() string ``` ```go cacheDir := paths.CacheDir() // Returns: "/tmp/claudeline" (Linux/Mac) // Returns: "C:\Users\user\AppData\Local\Temp\claudeline" (Windows) ``` -------------------------------- ### Check Peak Hours Usage Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/policy.md Example usage of the IsPeakHours function. Note that this currently always returns false as the feature is disabled. ```go import "github.com/fredrikaverpil/claudeline/internal/policy" func main() { now := time.Now() isPeak := policy.IsPeakHours(now, "Pro") // Currently always returns false if isPeak { println("Peak hours active") } else { println("Normal hours") // Always prints } } ``` -------------------------------- ### Check for Existing Claudeline Installation Source: https://github.com/fredrikaverpil/claudeline/blob/main/commands/setup.md Use this command to check if the claudeline binary is already present on your system. If found, note its path for potential updates. ```bash which claudeline ``` -------------------------------- ### Parse stdin and resolve credentials Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/quick-reference.md Initializes the application state by parsing input from stdin and resolving user credentials. ```go data, err := stdin.Parse(input) cred, loginType, isProvider := creds.Resolve(ctx, debugMode, configDir) ``` -------------------------------- ### Usage Pattern for Multi-Profile Caching Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/paths.md Demonstrates how to organize cache files based on the CLAUDE_CONFIG_DIR environment variable. ```go package main import "github.com/fredrikaverpil/claudeline/internal/paths" func main() { configDir := os.Getenv("CLAUDE_CONFIG_DIR") usageFile := paths.MustCacheFile(configDir, "usage.json") statusFile := paths.MustCacheFile(configDir, "status.json") debugFile := paths.MustCacheFile(configDir, "debug.log") // Each profile has its own cache files // /tmp/claudeline/usage.json (default profile) // /tmp/claudeline/usage-a1b2c3d4.json (work profile) } ``` -------------------------------- ### GET https://status.claude.com/api/v2/status.json Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/README.md Retrieves the current service status for Claude. ```APIDOC ## GET https://status.claude.com/api/v2/status.json ### Description Retrieves the current operational status of the Claude service. ### Method GET ### Endpoint https://status.claude.com/api/v2/status.json ``` -------------------------------- ### GET https://api.anthropic.com/api/oauth/usage Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/README.md Retrieves usage information for the authenticated OAuth session. ```APIDOC ## GET https://api.anthropic.com/api/oauth/usage ### Description Retrieves usage data for the current OAuth session. ### Method GET ### Endpoint https://api.anthropic.com/api/oauth/usage ### Authentication OAuth ``` -------------------------------- ### Detect OS and Architecture Source: https://github.com/fredrikaverpil/claudeline/blob/main/commands/setup.md These commands detect your operating system and architecture to determine the correct binary to download. ```bash OS=$(uname -s | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) case "$ARCH" in x86_64) ARCH="amd64" ;; aarch64) ARCH="arm64" ;; esac ``` -------------------------------- ### GET https://api.anthropic.com/api/oauth/usage Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/usage.md Retrieves usage statistics and rate limit information for OAuth-authenticated users. ```APIDOC ## GET https://api.anthropic.com/api/oauth/usage ### Description Retrieves current API usage metrics and rate limit status for OAuth users. This endpoint is restricted to Pro, Max, and Team subscription users. ### Method GET ### Endpoint https://api.anthropic.com/api/oauth/usage ### Headers - **Authorization** (string) - Required - Bearer - **Anthropic-Beta** (string) - Required - oauth-2025-04-20 ### Response #### Success Response (200) - **timestamp** (integer) - Unix timestamp of the request - **ok** (boolean) - Status of the request - **rate_limited** (boolean) - Whether the user is currently rate limited - **retry_after** (integer) - Seconds to wait before retrying if rate limited - **data** (object) - Usage utilization metrics for various time windows and models #### Response Example { "timestamp": 1689187200, "ok": true, "rate_limited": false, "retry_after": 0, "data": { "five_hour": {"utilization": 45.5, "resets_at": "2026-07-13T12:00:00Z"}, "seven_day": {"utilization": 60.2, "resets_at": "2026-07-18T00:00:00Z"}, "seven_day_sonnet": {"utilization": 55.1, "resets_at": "2026-07-18T00:00:00Z"}, "seven_day_opus": {"utilization": 70.0, "resets_at": "2026-07-18T00:00:00Z"}, "extra_usage": {"is_enabled": true, "monthly_limit": 50000, "used_credits": 12345} } } ``` -------------------------------- ### Handling Package Errors in Go Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/errors.md Demonstrates how to handle specific errors from the usage package while allowing credentials to fail silently. ```go package main import ( "github.com/fredrikaverpil/claudeline/internal/usage" "github.com/fredrikaverpil/claudeline/internal/creds" ) func main() { // Credentials may fail silently cred, loginType, isProvider := creds.Resolve(ctx, false, "") // Continue even if cred is empty // Usage API may fail with specific errors resp, err := usage.Fetch(ctx, token, cachePath) if errors.Is(err, usage.ErrCachedRateLimited) { log.Println("Rate limited, will retry later") } else if errors.Is(err, usage.ErrCachedFailure) { log.Println("Recent failure, cache valid, will retry later") } else if err != nil { log.Println("Other error:", err) } // Always proceed with what data is available if resp != nil { renderUsageBar(resp) } } ``` -------------------------------- ### Cache management usage pattern Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/jsonfile.md Demonstrates a typical workflow for reading and writing cache entries using the jsonfile package. ```go package main import "github.com/fredrikaverpil/claudeline/internal/jsonfile" // Cache entry with TTL type CacheEntry struct { Timestamp int64 `json:"timestamp"` OK bool `json:"ok"` Data *MyData `json:"data,omitempty"` } // Read from cache cached, err := jsonfile.Read[CacheEntry](cachePath) if err != nil { // Cache miss or invalid } // Write to cache jsonfile.Write(cachePath, CacheEntry{ Timestamp: time.Now().Unix(), OK: true, Data: response, }) ``` -------------------------------- ### Configure Context Compaction Thresholds Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Define custom thresholds for context compaction warnings based on window size and percentage overrides. ```bash # Claude Code sets auto-compaction at 95% of a 100k window export CLAUDE_CODE_AUTO_COMPACT_WINDOW=100000 export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=95 # Claudeline warns at (100000 × 90 / 100) = 90000 tokens claudeline # Shows ⚠️ when context > 90k tokens ``` -------------------------------- ### Configuration Environment Variables Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/README.md Environment variables for customizing directory paths and context window behavior. ```text CLAUDE_CONFIG_DIR Custom config directory CLAUDE_CODE_AUTO_COMPACT_WINDOW Effective context window (tokens) CLAUDE_AUTOCOMPACT_PCT_OVERRIDE Compaction percentage ``` -------------------------------- ### Enable Cost Display Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Configuration to show estimated session costs for subscription users. ```json { "statusLine": { "type": "command", "command": "claudeline -cost" } } ``` -------------------------------- ### Configure Custom Configuration Directory Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Set a custom directory for credential lookups and cache files. ```bash export CLAUDE_CONFIG_DIR=~/.claude-work claudeline # Uses work profile credentials and cache ``` -------------------------------- ### Configure Claudeline in settings.json (Full Path) Source: https://github.com/fredrikaverpil/claudeline/blob/main/commands/setup.md If the claudeline binary is not in your system's PATH, specify the full path to the binary in your settings.json file. ```json { "statusLine": { "type": "command", "command": "/claudeline" } } ``` -------------------------------- ### Configure Claudeline in settings.json (Binary in PATH) Source: https://github.com/fredrikaverpil/claudeline/blob/main/commands/setup.md If the claudeline binary is in your system's PATH, configure your settings.json file with this entry to use it as the statusline command. ```json { "statusLine": { "type": "command", "command": "claudeline" } } ``` -------------------------------- ### Construct Cache File Path Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/paths.md Generates a full path to a cache file, appending a profile-specific suffix. Panics if the provided filename lacks an extension. ```go func MustCacheFile(configDir, filename string) string ``` ```go // Default profile path := paths.MustCacheFile("", "usage.json") // Returns: "/tmp/claudeline/usage.json" // Custom profile path := paths.MustCacheFile("/home/user/.claude-work", "usage.json") // Returns: "/tmp/claudeline/usage-a1b2c3d4.json" // Debug log path := paths.MustCacheFile("", "debug.log") // Returns: "/tmp/claudeline/debug.log" ``` -------------------------------- ### Build and render status line Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/quick-reference.md Constructs the rendering parameters from resolved data and outputs the final status line. ```go params := render.Params{ LoginType: loginType, Model: data.Model.DisplayName, ContextUsedPct: data.ContextWindow.UsedPercentage, // ... other fields } statusLine := render.Build(params) fmt.Println(statusLine) ``` -------------------------------- ### Configure Full Featured Status Line Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Advanced configuration including working directory, git branch, and cost tracking flags. ```json { "statusLine": { "type": "command", "command": "claudeline -cwd -cwd-max-len 25 -git-branch -git-branch-max-len 20 -cost" } } ``` -------------------------------- ### Define Credentials File Format Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Required structure for the ~/.claude/.credentials.json file. ```json { "claudeAiOauth": { "accessToken": "sk-ant-...", "subscriptionType": "pro" } } ``` -------------------------------- ### CLI Flags Reference Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/README.md Available command-line arguments for controlling output and debugging behavior. ```text claudeline -cwd -git-branch -cost -debug Write to debug.log -cwd Show working directory -git-branch Show git branch -cost Show session cost -version Print version and exit ``` -------------------------------- ### Build Status Line Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Assembles the complete status line string using a Params struct. ```go params := render.Params{ LoginType: "Pro", Model: "Claude 3.5 Sonnet", ContextUsedPct: ptrFloat(45.0), ContextWindowSize: 200000, ShowCwd: true, Cwd: "/workspace/home", CwdMaxLen: 30, } statusLine := render.Build(params) fmt.Println(statusLine) ``` -------------------------------- ### Enable Debug Mode Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Configuration to enable debug logging to /tmp/claudeline/debug.log. ```json { "statusLine": { "type": "command", "command": "claudeline -debug" } } ``` -------------------------------- ### Run Claudeline testing commands Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/quick-reference.md Use these commands to capture live API responses or render outputs from existing testdata files. ```bash ./pok capture # Capture live API responses ./pok render # Render from captured testdata ./pok render -json # Render specific payload ``` -------------------------------- ### Authentication Environment Variables Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/README.md Environment variables used to define the authentication provider, listed in order of precedence. ```text CLAUDE_CODE_USE_MANTLE=1 → "Mantle" CLAUDE_CODE_USE_BEDROCK=1 → "Bedrock" CLAUDE_CODE_USE_VERTEX=1 → "Vertex" CLAUDE_CODE_USE_FOUNDRY=1 → "Foundry" ANTHROPIC_API_KEY → "API" ANTHROPIC_AUTH_TOKEN → "API" CLAUDE_CODE_OAUTH_TOKEN → "OAuth" File/Keychain → Subscription type ``` -------------------------------- ### func Output(identity, contextBar, usage5h, usage7d, cost, usageExtra, statusIndicator, updateIndicator string) string Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Assembles all segments into a single-line status output. ```APIDOC ## func Output(identity, contextBar, usage5h, usage7d, cost, usageExtra, statusIndicator, updateIndicator string) string ### Description Assembles all segments into a single-line status output. ### Parameters - **identity** (string) - Required - Identity segment. - **contextBar** (string) - Required - Context window bar. - **usage5h** (string) - Optional - 5-hour quota bar. - **usage7d** (string) - Optional - 7-day quota bar. - **cost** (string) - Optional - Formatted cost. - **usageExtra** (string) - Optional - Extra usage. - **statusIndicator** (string) - Optional - Service status indicator. - **updateIndicator** (string) - Optional - Update availability indicator. ### Returns - **string** - Complete status line ``` -------------------------------- ### Project Directory Structure Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/quick-reference.md Overview of the Claudeline Go source code organization. ```text claudeline/ ├── main.go Main orchestration ├── main_test.go Integration tests ├── internal/ │ ├── stdin/ │ │ ├── stdin.go │ │ └── stdin_test.go │ ├── creds/ │ │ ├── creds.go │ │ └── creds_test.go │ ├── usage/ │ │ ├── usage.go │ │ └── usage_test.go │ ├── status/ │ │ ├── status.go │ │ └── status_test.go │ ├── update/ │ │ ├── update.go │ │ └── update_test.go │ ├── render/ │ │ ├── render.go │ │ └── render_test.go │ ├── git/ │ │ ├── git.go │ │ └── git_test.go │ ├── paths/ │ │ ├── paths.go │ │ └── paths_test.go │ ├── jsonfile/ │ │ ├── jsonfile.go │ │ └── jsonfile_test.go │ └── policy/ │ ├── policy.go │ └── policy_test.go ``` -------------------------------- ### Create Context Color Function Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Generates a color function based on a specific warning threshold percentage. ```go colorFn := render.ContextColorFunc(80) bar := render.Bar(85, colorFn) // Output shows red bar with "85%" ``` -------------------------------- ### Resolve Credentials Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Determines the authentication method, returning credentials, login type, and provider status. ```go func Resolve(ctx context.Context, debugMode bool, configDir string) (Credentials, string, bool) ``` ```go cred, loginType, isProvider := creds.Resolve(ctx, false, "") if isProvider { println("Using provider:", loginType) // No OAuth token needed } else { println("Using subscription:", loginType) // Use cred.ClaudeAiOauth.AccessToken for API calls } ``` -------------------------------- ### FetchAsync(ctx context.Context, cachePath string, wg *sync.WaitGroup, out **Response) Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/status.md Fetches service status concurrently in a goroutine, writing results to an output pointer. ```APIDOC ## FetchAsync(ctx context.Context, cachePath string, wg *sync.WaitGroup, out **Response) ### Description Fetches service status concurrently in a goroutine, writing results to an output pointer. ### Parameters - **ctx** (context.Context) - Required - Context for request timeout. - **cachePath** (string) - Required - Path to cache file. - **wg** (*sync.WaitGroup) - Required - WaitGroup to signal completion. - **out** (**Response) - Required - Pointer to response pointer where result is stored. ``` -------------------------------- ### Render Progress Bar Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Generates a 5-character progress bar with ANSI colors and percentage. ```go bar := render.Bar(45, render.QuotaColor) // Output: "\033[94m██\033[2m░░░\033[0m 45%" ``` -------------------------------- ### func ContextColorFunc(warnPct int) func(int) string Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Returns a color function for context window usage zones. ```APIDOC ## func ContextColorFunc(warnPct int) func(int) string ### Description Returns a color function for context window usage zones. ### Parameters - **warnPct** (int) - Required - Warning threshold percentage. ### Returns - **func(int) string** - Color function for context bar percentage ``` -------------------------------- ### Define Subscription Type Constants Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Constants representing available subscription tiers. ```go const ( SubPro = "Pro" SubMax = "Max" SubTeam = "Team" SubEnterprise = "Enterprise" SubDebug = "Debug" ) ``` -------------------------------- ### Configure Minimal Status Line Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Basic configuration for the status line command. ```json { "statusLine": { "type": "command", "command": "claudeline" } } ``` -------------------------------- ### Define Provider Constants Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Constants representing supported API providers. ```go const ( ProviderBedrock = "Bedrock" ProviderMantle = "Mantle" ProviderVertex = "Vertex" ProviderFoundry = "Foundry" ProviderAPI = "API" ProviderOAuth = "OAuth" ) ``` -------------------------------- ### Write JSON to file Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/jsonfile.md Marshals a value to JSON and writes it to a file with 0o600 permissions. Note that this function does not return errors and will fail silently. ```go func Write[T any](path string, v T) ``` ```go // Define a struct type CacheEntry struct { Timestamp int64 `json:"timestamp"` Data string `json:"data"` } // Write to file entry := CacheEntry{ Timestamp: time.Now().Unix(), Data: "cached value", } jsonfile.Write("/tmp/cache.json", entry) // File created with permissions 0o600 ``` -------------------------------- ### Define Credentials Structure Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Data structure for storing OAuth access tokens and subscription information. ```go type Credentials struct { ClaudeAiOauth struct { AccessToken string SubscriptionType string } } ``` -------------------------------- ### Importing claudeline internal packages Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/quick-reference.md Use these import paths to access the internal modules of the claudeline project. ```go import ( "github.com/fredrikaverpil/claudeline/internal/creds" "github.com/fredrikaverpil/claudeline/internal/git" "github.com/fredrikaverpil/claudeline/internal/jsonfile" "github.com/fredrikaverpil/claudeline/internal/paths" "github.com/fredrikaverpil/claudeline/internal/policy" "github.com/fredrikaverpil/claudeline/internal/render" "github.com/fredrikaverpil/claudeline/internal/status" "github.com/fredrikaverpil/claudeline/internal/stdin" "github.com/fredrikaverpil/claudeline/internal/update" "github.com/fredrikaverpil/claudeline/internal/usage" ) ``` -------------------------------- ### FetchAsync Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/update.md Checks for a newer release concurrently in a goroutine. ```APIDOC ## func FetchAsync(ctx context.Context, currentVersion, cachePath string, wg *sync.WaitGroup, out **Response) ### Description Checks for a newer release concurrently in a goroutine, writing results to an output pointer. ### Parameters - **ctx** (context.Context) - Required - Context for request timeout. - **currentVersion** (string) - Required - Current version string. - **cachePath** (string) - Required - Path to cache file. - **wg** (*sync.WaitGroup) - Required - WaitGroup to signal completion. Must be non-nil. - **out** (**Response) - Required - Pointer to response pointer where result is stored. ``` -------------------------------- ### Fetch Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/update.md Checks for a newer release via the GitHub API with file-based caching. ```APIDOC ## func Fetch(ctx context.Context, currentVersion, cachePath string) (*Response, error) ### Description Checks for a newer release via the GitHub API with file-based caching. Returns non-nil only when a newer version is available. ### Parameters - **ctx** (context.Context) - Required - Context for request timeout (5 seconds). - **currentVersion** (string) - Required - Current version string (e.g., "v1.2.3", "1.2.3", "(devel)", "(unknown)"). - **cachePath** (string) - Required - Path to cache file (e.g., `/tmp/claudeline/update.json`). ### Returns - **Response** (*Response) - Release response if newer version available, nil if already on latest - **error** (error) - Network, parsing, or API error ``` -------------------------------- ### Cache File Locations Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/README.md Paths and TTL settings for local cache files used by the application. ```text /tmp/claudeline/usage.json 60s (success) / 15s (failure) /tmp/claudeline/status.json 2m (success) / 30s (failure) /tmp/claudeline/update.json 24h (success) / 15s (failure) /tmp/claudeline/debug.log Debug output (1MB truncate) ``` -------------------------------- ### func KeychainServiceName(configDir string) string Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Generates the appropriate macOS Keychain service name, including profile-specific hash suffixes. ```APIDOC ## func KeychainServiceName(configDir) ### Description Returns the macOS Keychain service name used by Claude Code, with a hash suffix for multi-profile support. ### Parameters - **configDir** (string) - Required - Claude Code config directory path. ### Returns - `string`: Keychain service name with optional hash suffix. ``` -------------------------------- ### Cache File Locations Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/quick-reference.md Default directory paths and file naming conventions for cache and log files across different operating systems. ```text /tmp/claudeline/ (Linux/macOS) %TEMP%\claudeline\ (Windows) usage.json (default profile) usage-{hash}.json (custom profile) status.json update.json debug.log ``` -------------------------------- ### func Build(p Params) string Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Assembles the complete status line string from all collected data. ```APIDOC ## func Build(p Params) string ### Description Assembles the complete status line string from all collected data. ### Parameters - **p** (Params) - Required - All parameters needed for rendering. ### Returns - **string** - Complete ANSI-formatted status line ``` -------------------------------- ### Define API Constants Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/usage.md Configuration constants for the API endpoint and cache TTL settings. ```go var usageURL = "https://api.anthropic.com/api/oauth/usage" const ( ttlOK = 60 * time.Second ttlFail = 15 * time.Second ttlRateLimitDefault = 5 * time.Minute ttlRateLimitMaxBackoff = 30 * time.Minute ) ``` -------------------------------- ### Visualize Claudeline Data Flow Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/architecture.md Represents the execution path from stdin input through credential resolution and concurrent data fetching to stdout rendering. ```text Claude Code ↓ (stdin JSON) main.readStdin() ↓ (stdin.Data) main.run() ├── creds.Resolve() │ ├── Check env vars (Provider) │ └── Read credentials (File/Keychain) │ ↓ (Credentials, loginType, isProvider bool) │ ├── fetchRemoteData() [concurrent via sync.WaitGroup] │ ├── usage.FetchAsync() → API/Cache → *usage.Response │ ├── status.FetchAsync() → API/Cache → *status.Response │ └── update.FetchAsync() → API/Cache → *update.Response │ └── render.Build(Params) ├── Identity segment (LoginType | Model) ├── Context bar (colored progress bar) ├── Quota bars (5h, 7d, per-model) ├── Service status (fire icon) ├── Update indicator (arrow) ├── Cost (session total) ├── Working directory └── Git branch ↓ (ANSI string) stdout → Claude Code ``` -------------------------------- ### FetchAsync function signature Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/status.md Fetches service status concurrently in a goroutine, writing results to an output pointer. ```go func FetchAsync(ctx context.Context, cachePath string, wg *sync.WaitGroup, out **Response) ``` -------------------------------- ### Fetch usage data with caching Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/usage.md Retrieves usage data from the API while respecting cache policies and rate limits. ```go func Fetch(ctx context.Context, token, cachePath string) (*Response, error) ``` ```go ctx := context.Background() resp, err := usage.Fetch(ctx, token, "/tmp/claudeline/usage.json") if err != nil { if errors.Is(err, usage.ErrCachedRateLimited) { println("Rate limited, please retry later") return } println("Error:", err) return } println("5-hour quota:", resp.FiveHour.Utilization, "%") println("7-day quota:", resp.SevenDay.Utilization, "%") ``` -------------------------------- ### func Read(ctx context.Context, configDir, keychainService string) (Credentials, error) Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Retrieves OAuth credentials from the macOS Keychain or a local file fallback. ```APIDOC ## func Read(ctx, configDir, keychainService) ### Description Reads OAuth credentials from macOS Keychain or file fallback. On macOS, it attempts to read from the Keychain first, then falls back to the specified config directory. ### Parameters - **ctx** (context.Context) - Required - Context with timeout for IO operations. - **configDir** (string) - Optional - Claude Code config directory (defaults to ~/.claude). - **keychainService** (string) - Required - macOS Keychain service name. ### Returns - **Credentials** (struct) - The OAuth credentials containing AccessToken and SubscriptionType. - **error** (error) - Keychain or file read error. ``` -------------------------------- ### func FetchAsync(ctx context.Context, token, cachePath string, wg *sync.WaitGroup, out **Response) Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/usage.md Fetches usage data concurrently in a goroutine, writing results to an output pointer. ```APIDOC ## func FetchAsync(ctx context.Context, token, cachePath string, wg *sync.WaitGroup, out **Response) ### Description Fetches usage data concurrently in a goroutine, writing results to an output pointer. ### Parameters - **ctx** (context.Context) - Required - Context for request timeout. - **token** (string) - Required - OAuth bearer token. - **cachePath** (string) - Required - Path to cache file. - **wg** (*sync.WaitGroup) - Required - WaitGroup to signal completion. Must be non-nil. - **out** (**Response) - Required - Pointer to response pointer where result is stored. ``` -------------------------------- ### Fetch(ctx context.Context, cachePath string) Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/status.md Fetches Claude service status from Atlassian Statuspage API with file-based caching. ```APIDOC ## Fetch(ctx context.Context, cachePath string) ### Description Fetches Claude service status from Atlassian Statuspage API with file-based caching. ### Parameters - **ctx** (context.Context) - Required - Context for request timeout (5 seconds). - **cachePath** (string) - Required - Path to cache file. ### Returns - **Response** (*Response) - Status response (may be cached or fresh from API) - **error** (error) - Network, parsing, or API error ``` -------------------------------- ### Configure Basic Status Line Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Standard JSON configuration for integrating Claudeline as a status line command. ```json { "statusLine": { "type": "command", "command": "/path/to/claudeline" } } ``` -------------------------------- ### Configure status line in settings.json Source: https://github.com/fredrikaverpil/claudeline/blob/main/CLAUDE.md Manual configuration for the status line command in the Claude Code settings file. ```jsonc { "statusLine": { "type": "command", "command": "/path/to/claudeline", }, } ``` -------------------------------- ### Read usage response from file Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/usage.md Reads a usage response directly from a JSON file without any caching logic. ```go func ReadResponse(path string) (*Response, error) ``` ```go usage, err := usage.ReadResponse("/tmp/usage.json") if err != nil { panic(err) } println(usage.SevenDay.Utilization) ``` -------------------------------- ### Fetch Function Definition Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/update.md Checks for a newer release via the GitHub API with file-based caching. ```go func Fetch(ctx context.Context, currentVersion, cachePath string) (*Response, error) ``` -------------------------------- ### DefaultConfigDir Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/paths.md Returns the default Claude Code configuration directory path. ```APIDOC ## func DefaultConfigDir() ### Description Returns the default Claude Code config directory path (typically ~/.claude). ### Returns - **string**: The absolute path to the default configuration directory. ``` -------------------------------- ### func Write[T any](path string, v T) Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/jsonfile.md Marshals a value as JSON and writes it to a file. ```APIDOC ## func Write[T any](path string, v T) ### Description Marshals a value to JSON and writes it to the specified file path with 0o600 permissions. Note that this function silently fails on marshal or write errors. ### Parameters - **path** (string) - Required - File path to write to. - **v** (T) - Required - Value to marshal as JSON. ### Type Parameters - **T** (any) - Required - Any type that can be JSON marshaled. ``` -------------------------------- ### func Bar(pct int, colorFn func(int) string) string Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Renders a progress bar with ANSI colors, percentage, and visual representation. ```APIDOC ## func Bar(pct int, colorFn func(int) string) string ### Description Renders a progress bar with ANSI colors, percentage, and visual representation. ### Parameters - **pct** (int) - Required - Percentage (0-100). Clamped to valid range. - **colorFn** (func(int) string) - Required - Function returning ANSI color code for given percentage. ### Returns - **string** - Formatted progress bar ``` -------------------------------- ### Set Custom Truncation Lengths Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/configuration.md Configuration to limit the display length of the working directory and git branch. ```json { "statusLine": { "type": "command", "command": "claudeline -cwd -cwd-max-len 15 -git-branch -git-branch-max-len 20" } } ``` -------------------------------- ### func Provider() string Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/creds.md Detects the active API provider based on environment variables following established precedence rules. ```APIDOC ## func Provider() ### Description Detects the API provider from environment variables following Claude Code's authentication precedence. ### Returns - `string`: One of "Bedrock", "Mantle", "Vertex", "Foundry", "API", "OAuth", or an empty string if no provider is detected. ``` -------------------------------- ### func Fetch(ctx context.Context, token, cachePath string) (*Response, error) Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/usage.md Fetches usage data from the API with file-based caching, respecting rate limits and failure states. ```APIDOC ## func Fetch(ctx context.Context, token, cachePath string) (*Response, error) ### Description Fetches usage data from the API with file-based caching. Respects cached rate limits and failures to avoid hammering the API. ### Parameters - **ctx** (context.Context) - Required - Context for request timeout control (5 seconds). - **token** (string) - Required - OAuth bearer token from credentials. - **cachePath** (string) - Required - Path to cache file. ### Returns - **Response** (*Response) - Usage data (may be cached or fresh from API) - **error** (error) - ErrCachedRateLimited, ErrCachedFailure, or API error ``` -------------------------------- ### ExtraUsage Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/render.md Returns the "$used/$limit" string for pay-as-you-go overage. ```APIDOC ## func ExtraUsage(used, limit int) string ### Description Returns the "$used/$limit" string for pay-as-you-go overage. Colors red when 80%+ of limit is used. ### Parameters - **used** (int) - Required - Amount used (in dollars). - **limit** (int) - Required - Monthly limit (in dollars). ### Returns - (string) - Formatted usage string or "" if used is zero. ``` -------------------------------- ### Define RateLimit structure Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/stdin.md Represents rate limit usage and reset information. ```go type RateLimit struct { UsedPercentage *float64 // Percentage used (0-100) ResetsAt *float64 // Unix timestamp when limit resets } ``` -------------------------------- ### Generate Configuration Directory Suffix Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/paths.md Computes a SHA256 hash suffix for a given configuration directory to prevent cache file collisions between different profiles. ```go func ConfigDirSuffix(configDir string) string ``` ```go // Default profile suffix := paths.ConfigDirSuffix("") // Returns: "" suffix := paths.ConfigDirSuffix("/home/user/.claude") // Returns: "" (matches default) // Custom profile suffix := paths.ConfigDirSuffix("/home/user/.claude-work") // Returns: "-a1b2c3d4" (hash of path) suffix := paths.ConfigDirSuffix("/home/user/.claude-personal") // Returns: "-e5f6g7h8" (hash of path) ``` -------------------------------- ### Define ExtraUsage Type Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/usage.md Structure for pay-as-you-go overage information. ```go type ExtraUsage struct { IsEnabled bool MonthlyLimit *float64 UsedCredits *float64 } ``` -------------------------------- ### Fetch usage data asynchronously Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/usage.md Executes a fetch operation in a separate goroutine and signals completion via a WaitGroup. ```go func FetchAsync(ctx context.Context, token, cachePath string, wg *sync.WaitGroup, out **Response) ``` ```go var wg sync.WaitGroup var resp *usage.Response usage.FetchAsync(ctx, token, cachePath, &wg, &resp) // Do other work... wg.Wait() // Block until fetch completes if resp != nil { println(resp.FiveHour.Utilization) } ``` -------------------------------- ### Fetch function signature Source: https://github.com/fredrikaverpil/claudeline/blob/main/_autodocs/api-reference/status.md Fetches Claude service status from Atlassian Statuspage API with file-based caching. ```go func Fetch(ctx context.Context, cachePath string) (*Response, error) ```