### Add Getting Started Guide to Help Page
Source: https://github.com/claude-code-best/claude-code/blob/main/progress.md
Integrates a 3-step 'Getting started' guide into the Help General page to assist new users.
```typescript
import { HelpGeneral } from "../src/components/HelpV2/General";
import { render, screen } from '@testing-library/react';
describe("Help General Page with Getting Started Guide", () => {
it("should display the new 3-step getting started guide", () => {
render();
// Check for the presence of the Getting Started section title
expect(screen.getByText(/Getting started/i)).toBeInTheDocument();
// Check for the 3 steps (example text)
expect(screen.getByText(/Step 1: Explore commands/i)).toBeInTheDocument();
expect(screen.getByText(/Step 2: Use shortcuts/i)).toBeInTheDocument();
expect(screen.getByText(/Step 3: Customize settings/i)).toBeInTheDocument();
// Ensure the old single paragraph description is not the primary content
expect(screen.queryByText(/This page provides a comprehensive list/i)).not.toBeInTheDocument();
});
});
// Mock HelpGeneral component if not available
if (typeof HelpGeneral === 'undefined') {
global.HelpGeneral = () => (
Getting started
Step 1: Explore commands
Step 2: Use shortcuts
Step 3: Customize settings
All shortcuts: ...
);
}
```
--------------------------------
### Install acp-link from Source
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/acp-link/README.md
Install the acp-link package from the monorepo root using bun.
```bash
# From monorepo root
bun install
```
--------------------------------
### Install Bun on Windows (PowerShell)
Source: https://github.com/claude-code-best/claude-code/blob/main/README_EN.md
Installs the latest version of Bun on Windows systems using PowerShell.
```powershell
powershell -c "irm bun.sh/install.ps1 | iex"
```
--------------------------------
### External MCP Server Configuration Examples
Source: https://github.com/claude-code-best/claude-code/blob/main/docs/extensibility/mcp-protocol.mdx
Provides examples of how to configure external MCP servers in JSON format, including stdio, http, sse, and ws types. These configurations specify how to run or connect to the MCP servers.
```json
// settings.json / .mcp.json 中的 MCP 配置
{
"mcpServers": {
// stdio 类型 — 启动子进程
"my-database": {
"command": "npx",
"args": ["@my-org/db-mcp-server"],
"env": { "DB_URL": "postgres://..." }
},
// HTTP 流类型 — 远程服务器
"remote-api": {
"type": "http",
"url": "https://api.example.com/mcp"
},
// SSE 类型 — Server-Sent Events
"realtime-feed": {
"type": "sse",
"url": "https://feed.example.com/sse"
},
// WebSocket 类型
"ws-service": {
"type": "ws",
"url": "wss://ws.example.com/mcp"
}
}
}
```
--------------------------------
### Install Bun on Linux and macOS
Source: https://github.com/claude-code-best/claude-code/blob/main/README_EN.md
Installs the latest version of Bun on Linux and macOS systems using a curl command.
```bash
curl -fsSL https://bun.sh/install | bash
```
--------------------------------
### Start RCS with Docker Compose
Source: https://github.com/claude-code-best/claude-code/blob/main/docs/features/remote-control-self-hosting.md
Command to start the services defined in the Docker Compose file.
```bash
docker compose up -d
```
--------------------------------
### Install Project Dependencies
Source: https://github.com/claude-code-best/claude-code/blob/main/README_EN.md
Installs all necessary project dependencies for Claude Code. This command must be run from the repository root.
```bash
cd /path/to/claude-code
bun install
```
--------------------------------
### Verify Bun Installation
Source: https://github.com/claude-code-best/claude-code/blob/main/README_EN.md
Checks if Bun is installed and available in the current terminal by displaying its help information and version.
```bash
bun --help
bun --version
```
--------------------------------
### Start Remote Control Server Daemon
Source: https://github.com/claude-code-best/claude-code/blob/main/DEV-LOG.md
CLI commands to start the remote control server daemon. Supports configuration for spawn mode and capacity.
```bash
bun run dev daemon start
bun run dev daemon start --spawn-mode=worktree --capacity=8
```
--------------------------------
### Auto Focus Example
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/10-events-and-focus.md
Demonstrates how to use the autoFocus prop to give an element focus immediately when it mounts.
```tsx
Receives focus immediately on mount
```
--------------------------------
### Width and Height Examples
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/02-layout.md
Demonstrates setting fixed or percentage-based dimensions for a Box component.
```tsx
... // Fixed 40 characters wide
```
```tsx
... // Fixed 10 rows tall
```
```tsx
... // 50% of parent's width
```
```tsx
... // Full parent width
```
--------------------------------
### Start Inspect Server for Debugging
Source: https://github.com/claude-code-best/claude-code/blob/main/README_EN.md
Start the inspect server in the terminal to enable VS Code debugging. This command outputs a WebSocket address for attaching the debugger.
```bash
bun run dev:inspect
```
--------------------------------
### Display Property Examples
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/02-layout.md
Shows how to control the visibility and layout behavior of a Box component.
```tsx
... // Visible (default)
```
```tsx
... // Hidden (removed from layout)
```
--------------------------------
### Run acp-link via Global Install
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/acp-link/README.md
Execute acp-link from a global installation, specifying the agent path.
```bash
# Via global install
acp-link /path/to/agent
```
--------------------------------
### Capture and Bubble Phase Example
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/10-events-and-focus.md
Demonstrates how to use onKeyDownCapture and onKeyDown to handle events during the capture and bubble phases, including stopping propagation.
```tsx
{
// Capture phase: fires top-down
console.log('Parent captures key')
}}
onKeyDown={(e) => {
// Bubble phase: fires bottom-up
console.log('Parent receives bubbled key')
}}
>
{
// Target: fires first in bubble phase
console.log('Child handles key')
e.stopImmediatePropagation() // Stop here
}}
>
Focus here
```
--------------------------------
### Tab Navigation Example
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/10-events-and-focus.md
Example of using tabIndex to control focusability and the onAction prop for handling button clicks during tab navigation.
```tsx
```
--------------------------------
### Example Status Line Script: Cache Hit Rate and TTL Countdown
Source: https://github.com/claude-code-best/claude-code/blob/main/docs/features/status-line.mdx
A default example script for the status line that displays cache hit rate and a TTL countdown. It handles per-session state persistence, color-coded output, and fallbacks for null usage data.
```bash
#!/bin/bash
# Example script for status line
# Outputs: | | ctx:N% | Cache X% SS:MM
# --- Configuration ---
STATE_FILE="~/.claude/statusline-state/$(echo -n "$SESSION_ID" | md5sum | head -c 16).state"
DEFAULT_HIT_RATE="?%"
DEFAULT_TTL="--:--"
# --- State Management ---
load_state() {
if [[ -f "$STATE_FILE" ]]; then
read -r signature timestamp hit_rate < "$STATE_FILE"
# Basic numeric validation
if [[ "$timestamp" =~ ^[0-9]+$ ]] && [[ "$hit_rate" =~ ^[0-9]+$ ]]; then
echo "$signature"
echo "$timestamp"
echo "$hit_rate"
return 0
fi
fi
echo ""
echo "0"
echo "0"
return 1
}
save_state() {
local signature="$1"
local timestamp="$2"
local hit_rate="$3"
mkdir -p "$(dirname "$STATE_FILE")"
echo "$signature"
echo "$timestamp"
echo "$hit_rate" > "$STATE_FILE"
}
# --- Helper Functions ---
get_color() {
local value=$1
local type=$2
if [[ "$type" == "hit_rate" ]]; then
if (( value >= 50 )); then echo "32"; # Green
elif (( value >= 20 )); then echo "33"; # Yellow
else echo "90"; # Gray
fi
elif [[ "$type" == "ttl" ]]; then
local ttl_minutes=$(( value / 60 ))
if (( ttl_minutes <= 5 )); then echo "1;31"; # Blinking Red
elif (( ttl_minutes <= 20 )); then echo "31"; # Red
elif (( ttl_minutes <= 40 )); then echo "33"; # Yellow
else echo "32"; # Green
fi
fi
}
# --- Main Logic ---
# Load current state
read -r last_signature last_timestamp last_hit_rate < <(load_state)
# Get current context usage (if available)
current_usage_json="$(cat)" # Read from stdin
# Parse current usage
current_signature="$(echo "$current_usage_json" | jq -r '.context_window.current_signature // ""')"
current_usage="$(echo "$current_usage_json" | jq -r '.context_window.current_usage // ""')"
# Calculate hit rate
if [[ -n "$current_usage" ]]; then
cache_read=$(echo "$current_usage" | jq '.cache_read // 0')
input=$(echo "$current_usage" | jq '.input // 0')
cache_creation=$(echo "$current_usage" | jq '.cache_creation // 0')
cache_total=$(( input + cache_creation + cache_read ))
if (( cache_total > 0 )); then
hit_rate=$(( cache_read * 100 / cache_total ))
else
hit_rate=0
fi
# Reset TTL only if signature changes
if [[ "$current_signature" != "$last_signature" ]]; then
timestamp=$(date +%s)
save_state "$current_signature" "$timestamp" "$hit_rate"
else
# Use last timestamp if signature is the same
timestamp="$last_timestamp"
save_state "$current_signature" "$timestamp" "$hit_rate"
fi
else
# Fallback to last known state if current_usage is null
hit_rate="$last_hit_rate"
timestamp="$last_timestamp"
current_signature="$last_signature"
# If no state, use defaults
if [[ "$last_hit_rate" == "0" && "$last_timestamp" == "0" ]]; then
hit_rate="$DEFAULT_HIT_RATE"
timestamp=$(date +%s)
fi
fi
# Calculate TTL
current_time=$(date +%s)
# Assuming 60 minutes = 3600 seconds for TTL
max_ttl=$(( 60 * 60 ))
elapsed_time=$(( current_time - timestamp ))
ttl=$(( max_ttl - elapsed_time ))
# Handle expired TTL
if (( ttl < 0 )); then
ttl=0
hit_rate="exp"
fi
# Format TTL for display
ttl_minutes=$(( ttl / 60 ))
ttl_seconds=$(( ttl % 60 ))
formatted_ttl="$(printf "%02d:%02d" "$ttl_minutes" "$ttl_seconds")"
# Determine colors
hit_color=$(get_color "$hit_rate" "hit_rate")
ttl_color=$(get_color "$ttl" "ttl")
# Output
# Use default values if hit_rate is not a number (e.g., 'exp')
if ! [[ "$hit_rate" =~ ^[0-9]+$ ]]; then
display_hit_rate="$hit_rate"
display_hit_color="90" # Gray for 'exp'
else
display_hit_rate="$hit_rate%"
display_hit_color="$hit_color"
fi
# Use default values if ttl is 0 and expired
if [[ "$ttl" == "0" && "$hit_rate" == "exp" ]]; then
formatted_ttl="exp"
display_ttl_color="90" # Gray for expired
else
display_ttl_color="$ttl_color"
fi
# Get current directory and model (simplified)
current_dir="$(pwd)"
current_model="$(echo "$current_usage_json" | jq -r '.model // "default"')"
# Print the status line
echo -e "\033[${display_hit_color}m${display_hit_rate}\033[0m | ${current_model} | ctx:${hit_rate}% | Cache ${formatted_ttl}"
```
--------------------------------
### Initialize Keybinding Setup
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/08-keybindings.md
Load and validate keybinding configuration at app startup using `KeybindingSetup`. It requires functions to load bindings, subscribe to changes, and handle validation warnings.
```tsx
import { KeybindingSetup } from '@anthropic/ink'
parseUserKeybindings(configFile)}
subscribeToChanges={(cb) => watchConfigFile(cb)}
onWarnings={(warnings, isReload) => {
warnings.forEach(w => console.warn(w.message))
}}
>
```
--------------------------------
### acp-link Basic Usage
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/acp-link/README.md
Start acp-link with the default settings, providing the path to the agent.
```bash
# Basic usage
acp-link /path/to/agent
```
--------------------------------
### Min/Max Dimension Examples
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/02-layout.md
Shows how to set minimum and maximum dimensions for a Box component, supporting percentage values.
```tsx
...
```
```tsx
...
```
```tsx
...
```
```tsx
...
```
```tsx
Percentage values are supported: `minWidth="30%"`.
```
--------------------------------
### Background Session Start Handler
Source: https://github.com/claude-code-best/claude-code/blob/main/docs/task/task-013-bg-engine-abstraction.md
Handles the initiation of a new background session by selecting the appropriate engine, generating a session name, defining the log path, and calling the engine's start method. It then logs the session details to the console.
```typescript
export async function handleBgStart(args: string[]): Promise {
const engine = await selectEngine()
const sessionName = `claude-bg-${randomUUID().slice(0, 8)}`
const logPath = join(getClaudeConfigHomeDir(), 'sessions', 'logs', `${sessionName}.log`)
const result = await engine.start({
sessionName,
args: filteredArgs,
env: { ...process.env, CLAUDE_CODE_SESSION_KIND: 'bg', ... },
logPath,
cwd: process.cwd(),
})
console.log(`Background session started: ${result.sessionName}`)
console.log(` Engine: ${result.engineUsed}`)
console.log(` Log: ${result.logPath}`)
console.log(` Use \`claude daemon attach ${result.sessionName}\` to reconnect.`)
}
```
--------------------------------
### Flex Wrap Examples
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/02-layout.md
Demonstrates how to control whether flex items wrap onto multiple lines.
```tsx
... // Single line (default)
```
```tsx
... // Multiple lines
```
```tsx
... // Reverse cross-axis stacking
```
--------------------------------
### Update First Fork Example with `fork: true`
Source: https://github.com/claude-code-best/claude-code/blob/main/spec/feature_20260502_F001_fork-agent-redesign/spec-plan.md
Adds the `fork: true` parameter to the first example within the `forkExamples` section in `prompt.ts` to explicitly demonstrate the new fork invocation method.
```typescript
Agent({
description: "Fork the current conversation to continue a multi-file refactor.",
fork: true,
subagent_type: "code-reviewer",
})
```
--------------------------------
### Flex Grow, Shrink, and Basis Examples
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/02-layout.md
Shows how to control the flexibility of children within a flex container.
```tsx
... // Grow to fill available space
```
```tsx
... // Don't shrink below intrinsic size
```
```tsx
... // Initial size before flex distribution
```
```tsx
... // Percentage basis
```
--------------------------------
### Margin Examples
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/02-layout.md
Shows how to add outer spacing around a Box component. Only integer values are supported.
```tsx
... // All sides
```
```tsx
... // Left and right
```
```tsx
... // Top and bottom
```
```tsx
... // Left only
```
```tsx
... // Right only
```
```tsx
... // Top only
```
```tsx
... // Bottom only
```
--------------------------------
### Padding Examples
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/02-layout.md
Illustrates how to add inner spacing within a Box component. Only integer values are supported.
```tsx
... // All sides
```
```tsx
... // Left and right
```
```tsx
... // Top and bottom
```
```tsx
... // Left only
```
```tsx
... // Right only
```
```tsx
... // Top only
```
```tsx
... // Bottom only
```
--------------------------------
### Example Component Tree Structure
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/01-getting-started.md
Illustrates a nested component structure using Ink's `Box` and `Text` components, demonstrating Flexbox layout for terminal output.
```tsx
HeaderLeftRight
```
--------------------------------
### Dialog with Custom Input Guide
Source: https://github.com/claude-code-best/claude-code/blob/main/packages/@ant/ink/docs/05-design-system.md
Customize the keyboard hint footer of a Dialog component using the `inputGuide` prop. This allows for dynamic guidance based on the dialog's state.
```tsx