About this page
Tutorial- What this page solves
- Your analysis repository contains raw counts and a set of scripts. You want Claude Code to help you understand the workflow, rerun the differential expression analysis, and keep a record of each run. But after installation, login may fail, or the agent may not know the project conventions, and it may delete raw data.
- Who it is for
- Graduate students and researchers using Claude Code for the first time. You have used the Claude web app or a command-line tool, but you have not written a CLAUDE.md or settings.json file.
- What you will have
- After reading, you will have: a claude command that starts normally, a way to confirm which credential is in effect, a CLAUDE.md, a .claude/settings.json (with read-only protection for raw data and deny rules), and a log and results directory from one run.
- Covers
- Install Claude Code and sign in with a subscription account or an API key
- Write the project's CLAUDE.md and .claude/settings.json, and set permissions
- Complete a first task in a research project, protect raw data and keep a run log
- Does not cover
- Native Windows and WSL details, see the section Choose: Windows native or WSL 2
- Comparison of costs for gateways, relays and domestic models, see "How to Use Codex and Claude Code in China"
- Complete syntax for subagents, hooks and MCP (the choice sections give only minimal examples)
- Commands and errors from older versions (listed one by one in the troubleshooting section)
Main steps
Step 1
Why this stepClaude Code is a coding agent that runs in the terminal. It reads code, runs commands and modifies files within a project directory. This page uses the command-line version as its main path. Installation requires only two decisions: whether to update automatically, and whether Node.js is needed.
On macOS, Linux and WSL, the native install script is the simplest option. It installs the program to ~/.local/bin, does not require administrator rights, and updates automatically in the background. On Windows, run the corresponding command in PowerShell. Homebrew, WinGet and npm can also install Claude Code, but they do not update automatically. For a comparison of the other routes, see "How to choose an installation method".
# macOS / Linux / WSL: native install (recommended, updates automatically in the background)
curl -fsSL https://claude.ai/install.sh | bash
# Stable channel: about one week behind latest, skipping releases with serious regressions
curl -fsSL https://claude.ai/install.sh | bash -s stable
# Windows PowerShell (prompt starts with PS)
irm https://claude.ai/install.ps1 | iex
# Windows CMD (prompt does not start with PS)
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
# Package managers (no automatic updates)
brew install --cask claude-code # stable channel; claude-code@latest for the latest channel
winget install Anthropic.ClaudeCode
# npm (requires Node.js 22+; do not use sudo)
npm install -g @anthropic-ai/claude-code
npm install -g @anthropic-ai/claude-code@latest # use this to upgrade, not npm update -g
# Verify
claude --version # output recorded on this page: 2.1.296 (Claude Code)
claude doctor # read-only diagnostics: install method, automatic updates, settings file validationStep 2
Why this stepClaude Code calls the model, so it needs an account or an API key. The first time you run claude, it opens a browser for sign-in. After that, the credential is stored on your machine and you do not need to sign in again each time.
On macOS, login credentials are stored in the Keychain. On Linux and Windows, they are stored in ~/.claude/.credentials.json. If several kinds of credentials exist at the same time, Claude Code selects one according to a fixed order. Run /status to see which one is in effect.
For the differences between subscription accounts, API keys, gateways and third-party cloud platforms, see "How to choose a login method". The free plan does not include Claude Code. If requests still fail authentication after login, see the troubleshooting entry “Subscription login works normally, but requests fail with an authentication error”.
claude # first run: follow the prompts to sign in to your claude.ai account in the browser
/status # run inside a session: shows the account, gateway address and the active credentialStep 3
Why this stepCLAUDE.md is an instruction file that is read at the start of every session. It describes how Claude should work: where the data is, how to run things, and what the statistical conventions are. It affects how Claude works, but it does not restrict what Claude can do. Restrictions that must be enforced should be written as permission rules, as described in the next step.
Run claude in the project root directory, then enter /init. It generates a draft based on the code. If a file already exists, it only suggests changes. Drafts are usually long, so trim the draft to the essential rules and keep it under 200 lines. An example for a research project follows.
# Project: differential expression analysis of single-cell data
## Directory conventions
- data/raw/: raw data, read-only. Do not modify, move or delete it, and do not decompress or sort it in place.
- data/processed/: generated from raw by the scripts in scripts/; can be deleted and rebuilt at any time.
- scripts/: all analysis steps, numbered 01_, 02_, and so on. Each script can run independently.
- results/: figures and tables, with filenames that include the script number, for example 03_volcano.pdf.
- logs/: log for each run, with timestamps in the filenames.
## Runtime environment
- Use the conda environment scrna-2026 (versions locked in environment.yml). Ask me before installing any new package.
- Run scripts with: python scripts/<name>.py 2>&1 | tee logs/$(date +%Y%m%d-%H%M%S)-<name>.log
## Reproducibility requirements
- Fix seed=20261010 for all random processes, and record it in the metadata of the results tables.
- Every number in the results must be reproducible by a script in scripts/. Do not calculate numbers by hand in the conversation.
- When changing analysis parameters, update both the parameter table in docs/params.md and the reason for the change.
## Statistical conventions
- Differential expression uses the Wilcoxon test with BH correction, padj < 0.05 and |log2FC| > 1.
- data/raw/metadata.csv is the reference for sample information. Keep group names as they are.
## Long tasks
- For commands expected to take more than 5 minutes, run them in the background with nohup, write a log, and then read the log to report progress.
<!-- Maintenance note: this HTML comment is not loaded into Claude's context -->
See @docs/params.md for current parameters.Step 4
Why this stepThe permission mode determines which actions run without confirmation. Rules in settings.json then allow or block specific actions on top of the mode. Raw data cannot be regenerated, so this step does two things: it sets data/raw to read-only with file permissions, and it uses deny rules to block Claude's own editing tools from changing it.
In the settings.json below, acceptEdits lets reading and writing files pass automatically. allow permits running scripts and checking git status. ask requires confirmation first for operations such as pushing code and installing dependencies. deny blocks edits to data/raw and forced deletion. Deny rules apply in every mode, including bypassPermissions.
Place this file at .claude/settings.json in the repository so it can be shared with the repository. Do not put personal credentials in this file.
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"defaultMode": "acceptEdits",
"allow": [
"Bash(python scripts/*)",
"Bash(Rscript scripts/*)",
"Bash(git diff *)",
"Bash(git status)"
],
"ask": [
"Bash(git push *)",
"Bash(pip install *)",
"Bash(conda install *)"
],
"deny": [
"Edit(data/raw/**)",
"Bash(rm -rf *)",
"Read(./.env)"
]
},
"env": { "BASH_DEFAULT_TIMEOUT_MS": "600000" },
"cleanupPeriodDays": 365
}# Set raw data to read-only at the OS level (tested on this page: afterwards, Python append writes fail with PermissionError, and rm -f fails with Permission denied)
chmod -R a-w data/raw
# Unlock it yourself when you need to update the raw data
chmod -R u+w data/rawStep 5
Why this stepThe previous steps support this one: Claude can read, change and run things within the project, raw data is not modified, and every run can be traced. Long-running steps are handed to the background so they do not hold up the session.
nohup python scripts/05_train.py --config configs/run3.yaml \
> logs/run3-$(date +%Y%m%d-%H%M).log 2>&1 &
echo $! > logs/run3.pid
# On an HPC cluster, submit to the scheduler instead of running in the foreground on the login node
sbatch scripts/05_train.slurm
# Ask Claude to read the log and report after the background job finishes
tail -n 50 logs/run3-*.log- 01
Run once in the repository directory first
Enter the repository directory, run claude, and accept the trust dialog. The allow rules in project settings take effect only for trusted directories. Do this first for a newly cloned repository or a new directory on a cluster.
- 02
Confirm the plan in plan mode first
Before changing the analysis workflow, press Shift+Tab to switch to plan mode, or add /plan before your prompt. Claude reads files and writes a plan. You can edit the plan in your editor with Ctrl+G, and then approve it for execution. The plan file is reloaded from disk after compaction, so it works well as an outline for long tasks.
- 03
Activate the environment before starting claude
Each Bash command runs in its own process, so variables set with export are not kept for the next command. As a result, conda activate run in the middle of a session applies only to that one command. Run conda activate first, then start claude. If you need extra variables, use CLAUDE_ENV_FILE to point to a startup script.
- 04
Run long steps in the background and let Claude read the logs
For long steps such as model training or molecular simulation, start them with nohup or a job scheduler and write the output to a file. Then ask Claude to read the log and report progress. The pattern below is for asking Claude to start a long task.
- 05
Keep a record of the process
Session records are stored in JSONL format under ~/.claude/projects/<directory name>/ and are deleted after 30 days by default. For projects that need to keep records, raise cleanupPeriodDays in settings.json (for example to 365). Export key sessions as text with /export, and commit them to the repository together with the run logs in logs/.
Choose by your situation
Choose
Every route installs the same native binary. The differences are whether it updates automatically, whether Node.js is required, and which interface you use it in.
Older tutorials required installing Node.js first. Now only the npm route needs Node.js, version 22 or higher. With an older version, npm only prints an EBADENGINE warning, and the installation still completes.
| Route | Command or entry point | Automatic updates | Suitable for | Notes |
|---|---|---|---|---|
| Native install script | curl -fsSL https://claude.ai/install.sh | bash | Yes, updates in the background | Personal computers, WSL, servers without root | Installs to ~/.local/bin without administrator rights; open a new terminal after installing before running claude |
| Homebrew | brew install --cask claude-code | No, use brew upgrade | macOS machines already managed with brew | claude-code follows the stable channel; claude-code@latest follows the latest channel |
| WinGet | winget install Anthropic.ClaudeCode | No, use winget upgrade | Native Windows | Upgrading while running may fail if files are locked |
| npm | npm install -g @anthropic-ai/claude-code | Yes, but the global directory must be writable | Existing Node 22+ environment | npm only downloads the native binary; Node is not used at runtime. Do not use sudo |
| apt / dnf / apk | Official signed repository | No | Deployed centrally by cluster administrators | Suitable for machines with an NFS-shared home directory; see the cluster section below |
| Desktop app | claude.com/download | Yes | If you do not want to use a terminal | The Linux version has separate documentation; the GUI shows diffs and parallel sessions |
| VS Code / JetBrains extension | Search for Claude Code in the extension marketplace | Follows the extension | Viewing diffs inside the IDE | The starting permission mode of the VS Code extension reads the extension's own settings, not the project settings |
| Web cloud session | claude.ai/code | Not needed | Long tasks, continuing after going offline | Subscription accounts only, and a GitHub repository must be connected; API keys set locally do not apply |
Choose
Most HPC cluster home directories are shared over NFS, so the installation location should be chosen with this in mind.
A running session keeps reading the executable. If another node upgrades in place with npm, the old binary is deleted, and the running session exits with Bus error. See troubleshooting: Bus error. On a cluster, install the binary on a local disk, or set DISABLE_UPDATES and have an administrator upgrade it centrally.
The problem where older versions exited immediately after starting on SLURM compute nodes was fixed in 2.1.76 (GitHub #12507).
On a server without root, the native install script installs to ~/.local/bin and requires neither Node nor root. The approach of a CSDN author, who installed Node with nvm and then installed Claude Code with npm, also works. However, the same post points ANTHROPIC_DEFAULT_HAIKU_MODEL to the retired claude-3-5-haiku. Change it to a model that the gateway currently provides. See "Use a gateway by setting ANTHROPIC_BASE_URL".
Choose
If your project and toolchain are on Windows, use native Windows. If you depend on a Linux toolchain (conda, gcc, HPC scripts) or need a sandbox, use WSL 2.
If you install with npm inside WSL and get exec: node: not found, see troubleshooting. Switching to the native install script avoids this kind of problem.
Native Windows
No administrator rights are needed. Git for Windows is optional: if it is installed, commands run in Git Bash; if not, it falls back to the PowerShell tool. If Claude Code cannot find Git Bash, set CLAUDE_CODE_GIT_BASH_PATH in the env section of settings.json to C:\Program Files\Git\bin\bash.exe. Native Windows does not support the Bash sandbox.
WSL 2
Run the Linux install script in a WSL terminal, not in PowerShell. Keep the project under /home. Reading and writing under /mnt/c across file systems is slow, and the official documentation notes that search may return fewer results, while claude doctor still shows Search OK.
Choose
When several credentials exist at the same time, Claude Code selects one according to a fixed order. Which method to choose depends on whether you use a subscription quota, pay per token, or access the service through a gateway or cloud platform.
From highest to lowest priority, the credential order is: cloud provider variables (CLAUDE_CODE_USE_BEDROCK and similar), ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY, the apiKeyHelper script, CLAUDE_CODE_OAUTH_TOKEN, and browser login. If a subscription user has an expired ANTHROPIC_API_KEY left in the shell, authentication fails. See troubleshooting.
If one machine has two accounts, separate them with CLAUDE_CONFIG_DIR, for example alias claude-lab='CLAUDE_CONFIG_DIR=~/.claude-lab claude'.
After upgrading your plan on claude.ai, tokens in existing sessions still reflect the old plan. Selecting Opus then shows a message that the plan is not available. See troubleshooting.
If the browser cannot call back to the local port (for example when logging in over WSL, SSH or in a container), the login page shows a code. Paste it at the Paste code here if prompted line in the terminal. If the browser does not open automatically, press c to copy the login link.
| Method | How to set up | Billing | Differences |
|---|---|---|---|
| Claude subscription (Pro, Max, Team, Enterprise) | Run claude and sign in to your claude.ai account in the browser | Included in the subscription, limited by the 5-hour session quota and the weekly quota | Prompt cache lifetime is 1 hour; Web cloud sessions and Remote Control are available; the free plan does not include Claude Code |
| Console API key | export ANTHROPIC_API_KEY=... In interactive mode you must confirm its use the first time | Billed per token; see the pricing table below | Prompt cache is 5 minutes by default; the dollar amounts shown by /usage are local estimates based on list prices |
| Gateway or relay (ANTHROPIC_BASE_URL) | ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY | Follows the gateway provider's rules | Remote Control is not available; MCP tool search is off by default; model names must be mapped with environment variables |
| Bedrock / Agent Platform / Foundry | CLAUDE_CODE_USE_BEDROCK=1 and similar, or select 3rd-party platform on the login page | Follows the cloud provider's billing | auto mode supports only newer models such as Sonnet 5 and Opus 4.7 and above |
| Long-lived token | claude setup-token generates a token valid for one year; set it as CLAUDE_CODE_OAUTH_TOKEN | Subscription | Used for CI and servers without a browser; --bare mode does not read it |
Choose
For choosing a solution in China (official subscriptions, relays, domestic models, cloud environments), see the comparison page "How to Use Codex and Claude Code in China". This section covers only the steps: where to put the variables and how to verify them.
The model specified by ANTHROPIC_DEFAULT_HAIKU_MODEL also handles background tasks such as session titles and summaries. It should point to a model the gateway currently provides, not a retired older model.
If the same variable is set both in the shell and in the env section of settings.json, settings.json takes precedence. Setting CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 also turns off automatic updates, so you will need to run claude update manually on a regular basis.
For specific errors when using a gateway, see the gateway entries in troubleshooting. Most of these errors are related to the gateway address, credential variables or model names.
# Export the two variables in the shell first, then use a request with 1 token to verify the address and credential
export ANTHROPIC_BASE_URL=https://gateway.example.com
export ANTHROPIC_AUTH_TOKEN=sk-xxxx
curl -sS -w '\n%{http_code}\n' -X POST "$ANTHROPIC_BASE_URL/v1/messages" \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
-H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-6","max_tokens":1,"messages":[{"role":"user","content":"."}]}'
# A response starting with {"id":"msg_... means success; an 'unknown model' error also means the address and credential are correct; for 401, switch to the x-api-key header and ANTHROPIC_API_KEY
# After starting claude, run /status and confirm that the Anthropic base URL and Auth token lines appear{
"env": {
"ANTHROPIC_BASE_URL": "https://gateway.example.com",
"ANTHROPIC_AUTH_TOKEN": "sk-xxxx",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "model name provided by the gateway",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "lightweight model name provided by the gateway",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "128000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
"API_TIMEOUT_MS": "600000"
}
}Choose
If you use it several hours a day, a subscription is more suitable. If you use it occasionally, in scripts or in CI, or need precise accounting, choose the API. The table below shows official public list prices as of 2026-10-10 (US dollars, before tax).
Reference for actual spending
Official data for enterprise deployments: on average, about $13 per person per active day, $150–250 per month, and 90% of users are below $30 per active day.
Cache lifetime determines the cost of leaving and returning
Subscription prompt cache lifetime is 1 hour; the API key default is 5 minutes. If you use an API key and ask a question after being idle for more than 5 minutes, the entire context is read again at the uncached price. In a long session, even a short question is billed for the whole context.
Check usage
/usage (/cost and /stats are aliases) shows the tokens and estimated amount for the current session. Subscription users see the quota bar and reset time. A warning appears at around 85% of the quota. If the Opus or Sonnet quota is used up, switch to the other model family with /model to continue. The weekly and session quotas are shared across models.
Set limits for scripts
claude -p supports --max-budget-usd and --max-turns, and stops when the limit is reached. The dollar amount is estimated on the client side and may be slightly exceeded, so leave a margin.
Routine practices for controlling costs
The status bar can be configured to show context usage and cost (/statusline). Use Sonnet for daily work, and switch to Opus for complex planning. For simple subagents, specify model: haiku. Start a new session for each independent question, because a long session is billed for the entire context even if you ask only one short question.
| Plan | Price | Notes |
|---|---|---|
| Free | $0 | Does not include Claude Code |
| Pro | $20 per month billed monthly; $17 per month effective when billed annually ($200 billed once) | Includes Claude Code; the quota is calculated over a 5-hour session window and a weekly window |
| Max | From $100 per month; choose 5x or 20x Pro usage | Priority access during peak times; includes a monthly API credit |
| API: Claude Sonnet 5.5 | Input $2 / output $10 per million tokens; cache hit $0.10 | Default choice for everyday coding |
| API: Claude Opus 5.5 | Input $4 / output $20; cache hit $0.20 | Complex planning and multi-step reasoning |
| API: Claude Haiku 5.5 | Input $0.10 / output $0.50 (when the prompt exceeds 100K tokens, $0.50 / $2.50) | Simple tasks for subagents |
| API: Claude Fable 5.1 | Input $10 / output $50; cache hit $0.25 | Highest tier |
Choose
The permission mode determines which actions run without confirmation. If no permission mode is configured, interactive sessions default to auto mode (since 2.1.283). For research projects, choose according to the task.
To restore confirmation for each action, press Shift+Tab to switch to default, or set permissions.defaultMode to default in the user-level ~/.claude/settings.json. For which file the mode-switching setting should go in, see troubleshooting.
| Mode | Runs without confirmation | Use in research |
|---|---|---|
| default (shown as Manual in the interface) | Read-only operations | First contact with unfamiliar code, or handling sensitive data |
| acceptEdits | Reading and editing files, plus mkdir, touch, rm, rmdir, mv, cp and sed inside the working directory | Review with git diff as you go; raw data must be protected separately |
| plan | Reading files and exploratory commands; no source changes until the plan is approved | Propose a plan before changing the analysis workflow; /plan prefix can also enter it for a single prompt |
| auto | Almost all operations, reviewed in the background by a separate classifier model | Long tasks with a clear direction; interactive sessions default to this mode since 2.1.283 |
| dontAsk | Runs only operations already allowed in allow; everything else is refused directly | Unattended claude -p batch jobs and CI |
| bypassPermissions | Everything (except deny rules, ask rules and deletion of critical paths) | Use only in containers or virtual machines without network access; startup is refused when running as root or with sudo |
Choose
claude -p runs once and outputs the result, which suits scripts and batch processing. Before batch processing, first confirm that it works correctly in that directory.
# Single run; the result is written as JSON so scripts can read result, session_id and total_cost_usd
claude -p "Read results/03_de_genes.csv and list the 20 genes with the smallest padj, with their log2FC" \
--output-format json --permission-mode dontAsk --allowedTools "Read" \
--max-turns 5 --max-budget-usd 0.50 < /dev/null > logs/summary.json
jq -r '.result' logs/summary.json
# Batch: one independent run per sample; a non-zero exit code on failure
for s in S01 S02 S03; do
claude -p "Check the cell count, gene count and mitochondrial fraction distribution of data/processed/$s.h5ad, and write a short QC conclusion" \
--permission-mode dontAsk --allowedTools "Read" "Bash(python scripts/qc_summary.py *)" \
< /dev/null > logs/qc-$s.md || echo "$s failed" >> logs/failed.txt
done
# Session resume
claude --continue # most recent interactive session in the current directory
claude --resume # open the session list (Ctrl+A shows all projects on this machine)
claude --resume de-analysis # resume by name (name it inside a session with /rename de-analysis)
claude -p --resume <session-id> "Summarize which parameters changed in this session" --output-format json | jq -r '.result'Run once interactively in the directory first
When claude -p runs in an untrusted directory, all allow rules in the project settings are ignored, while env in the same file still applies. For a newly cloned repository or a new directory on a cluster, first run claude once and accept the trust dialog. See troubleshooting.
stdin and exit codes
Add < /dev/null in scripts to keep claude -p from waiting for standard input. When not logged in, stdout prints Not logged in · Please run /login and the exit code is 1 (tested on this page). In -p mode, a settings file that fails validation is silently ignored, so run claude doctor before batch processing.
-p sessions are not in the list
Sessions created by claude -p do not appear in the list shown by claude --resume, and claude --continue does not select them. Use the session_id returned by --output-format json with claude --resume <id> to continue. When resuming a session, startup flags such as --mcp-config, --add-dir and --settings must be passed again.
Starting permission mode for -p
The starting mode of claude -p varies by version and by whether feature flags are fetched. It may be default or auto. Explicitly specifying --permission-mode dontAsk with an --allowedTools allowlist in scripts gives the most predictable results.
Choose
The four have different roles: a subagent completes one kind of task in its own independent context; a hook runs a shell command at fixed points, and its result does not depend on the model's judgment; a skill is a set of operating steps loaded on demand; MCP connects external tools and data. The minimal examples follow.
---
name: stats-reviewer
description: Reviews analysis scripts and result tables for statistical errors. Use after an analysis script changes or before results go into a figure or manuscript.
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a statistical methods reviewer. Check: whether sample sizes and groups match data/raw/metadata.csv; whether multiple comparisons are corrected;
whether random seeds are fixed; whether numbers in the result tables can be regenerated by the scripts in scripts/. Report only problems and evidence; do not modify files.#!/bin/bash
# .claude/hooks/protect-raw.sh: blocks Edit/Write writes to data/raw/
# Exit code 2 blocks the action; the stderr text is returned to Claude as the reason
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
FILE_PATH="${FILE_PATH//\\//}"
if [[ "$FILE_PATH" == *"/data/raw/"* ]]; then
echo "Blocked: $FILE_PATH is raw data (read-only). Write to data/processed/ or results/." >&2
exit 2
fi
exit 0{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{ "type": "command", "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/protect-raw.sh" }
]
}
]
}
}---
name: run-analysis
description: Run one analysis script reproducibly and log the environment. Use when the user asks to run or rerun an analysis.
disable-model-invocation: true
---
1. Record `git rev-parse --short HEAD`, `python --version` and `conda env export --no-builds` to logs/.
2. Run with `python scripts/$ARGUMENTS 2>&1 | tee logs/$(date +%Y%m%d-%H%M%S)-run.log`.
3. Report the output file paths and key numbers; do not modify data/raw/.# Add an MCP server (default local scope: applies only to you in the current project; written to ~/.claude.json)
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
claude mcp add my-db -e DB_URL=postgres://... -- npx -y some-db-mcp
# Shared with the lab: written to .mcp.json in the project root (teammates must approve it the first time they run claude)
claude mcp add --scope project zotero -- npx -y zotero-mcp
claude mcp list # servers in an unapproved .mcp.json appear as Pending approval
# Check agent and skill file format (tested on this page: a missing description only produces a warning, but the agent is skipped at runtime)
claude plugin validate .claude/agentsHooks are more reliable than CLAUDE.md
A PreToolUse hook that returns deny or exit code 2 blocks the action, even in bypassPermissions mode. A hook that returns allow cannot override a deny rule in settings. PostToolUse runs after the tool has executed and cannot undo the action. Command hooks time out after 10 minutes by default.
The subagent's system prompt
A subagent's system prompt contains only the file body and environment information such as the working directory. It cannot see the main session's conversation. Write the background it needs into the body, or explain it when delegating.
MCP configuration is not written in settings.json
Personal MCP servers are stored in ~/.claude.json, and servers shared by the project are stored in .mcp.json in the project root. Prefer command-line tools (gh, aws) when they can do the job, because MCP servers take up context. Use /mcp to disable servers you are not using for now. When using a gateway through ANTHROPIC_BASE_URL, MCP tool search is off by default, and all tool definitions enter the context.
Division of labor between skills and CLAUDE.md
Facts that must be followed every time belong in CLAUDE.md. Multi-step operating procedures belong in a skill, which is loaded only when invoked. disable-model-invocation: true means it can be invoked only by you, with /name. After compaction, each skill keeps only the first 5000 tokens at most, so put key steps near the top of SKILL.md.
Choose
Context is everything the model can see at one time, including the conversation, files and command output. In long tasks it fills up first, so it must be managed actively.
- 01
Check usage first
/context shows how much space the system prompt, Memory files, MCP tools and the conversation each take. If a large share is used at startup, CLAUDE.md, skills or MCP are too large and should be trimmed.
- 02
Use /clear when switching tasks
Old conversation unrelated to the current task is billed again in every request. Before switching tasks, name the session with /rename, then run /clear. /clear itself has no cost, but /compact reads the entire conversation, so with a large context it is itself a large request.
- 03
Specify what to keep when compacting
/compact keeps the parameter table, the last error and the steps not yet finished. You can also add a section titled # Compact instructions to CLAUDE.md to specify what to keep during compaction. /autocompact 300000 makes automatic compaction trigger earlier.
- 04
Read large data files in segments
Ask Claude to inspect structure with head, wc -l, the nrows option in pandas, or df.info(). Do not read an entire CSV. Oversized output can fill the context again right after compaction. See troubleshooting: Autocompact is thrashing.
- 05
Limits on command output
By default, only about 30000 characters of Bash output enter the context directly. Output beyond that is saved to a file that Claude reads on demand. For failed commands, only about 10000 characters from the beginning and end are kept. For lengthy logs, use grep or tail before passing them to Claude.
Hand off to an agent
Example instruction: "This is my analysis repository. First, read the code and data/README.md, without making changes. Then write a CLAUDE.md and .claude/settings.json following the directory conventions on this page, and set data/raw to read-only. Next, rerun the differential expression analysis from the raw counts using the workflow in scripts/, run long steps in the background and write logs, and finally give me the results table, figures, and a record of the parameters and environment."
Steps the agent will carry out: clone the repository in an isolated cloud computer and create the environment from environment.yml; propose a plan first, then generate CLAUDE.md and the permission configuration; when a GPU is needed, rent one automatically for the task, run long steps in the background and report progress by reading the logs; review the results adversarially, checking sample groups, multiple-comparison correction and random seeds.
Output files: CLAUDE.md, .claude/settings.json, the run log for each step, the tables and figures in results/, and a reproduction note recording the git commit hash and the conda environment. The task continues after your local machine is turned off.
You still need to check yourself: whether the statistical method suits your experimental design, whether groups and covariates match the sample information, and whether thresholds and parameters follow the lab's previous analysis conventions.
Concepts and judgment
Principle
CLAUDE.md is context that tells Claude how it should work. It is not enforced configuration. GitHub #2544 also records cases where enforced rules in CLAUDE.md were ignored. For this reason, red lines such as "ask me before deleting" or "do not push" should be written as ask or deny rules in settings.json, or as PreToolUse hooks.
Permission rules apply on top of the mode. A hook runs a shell command at a fixed point, and its result does not depend on the model's judgment. A PreToolUse hook that returns deny or exit code 2 blocks the action, even in bypassPermissions mode.
Principle
Read and Edit rules apply to the built-in file tools, and to the cat, sed, tee and redirections that Claude Code can recognize. They do not apply to open() or write.csv() inside Python or R scripts, and the .claudeignore file has no effect at all.
The reliable way to protect raw data is operating-system-level chmod -R a-w, plus a PreToolUse hook that blocks writes.
acceptEdits automatically approves rm inside the working directory. Checkpoints (Esc Esc or /rewind) roll back only files that Claude changed with its editing tools; they do not track files deleted or moved by Bash commands. The official critical-path protection blocks only rm on the root directory, the home directory and the working directory itself; it does not protect data/ under the working directory.
Reference and appendix
Reference
Multiple files are concatenated
All files found are concatenated in order from the root directory to the startup directory, and they do not override one another. If two rules conflict, Claude may pick either one, so do not write contradictory requirements at different levels.
@ imports
@path is resolved relative to the directory of the file containing that line, with up to 4 levels of recursion. If the path contains spaces, escape them with a backslash; if the path is quoted, it is not imported; if it is inside backticks, it is not imported. Imported files are fully loaded at startup and do not save context. When a project file imports a path outside the project, a one-time approval dialog appears.
Length
The official guidance is to keep each file under 200 lines. Longer files trigger a warning at startup and in /status, and files over 4 MiB are skipped. Move rules that apply only in some directories to a CLAUDE.md in a subdirectory or to .claude/rules/. HTML comments <!-- --> are not loaded into context, so they can hold maintenance notes meant for people.
Confirm whether a file is loaded
Run /context to see the files loaded at startup under Memory files. CLAUDE.md files in subdirectories do not appear there; when they are loaded, a Loaded line appears in the terminal. /memory opens them for editing directly. /init generates a draft based on the code, and if a file already exists, it only suggests changes.
Do they survive compaction
After /compact, the CLAUDE.md in the project root and rules without paths are reloaded from disk. CLAUDE.md files in subdirectories and rules with paths return only when related files are read or written again. Requirements that were stated only in the conversation are summarized away. Requirements that must always hold should go in the root CLAUDE.md.
Coexistence with AGENTS.md
When a directory contains both CLAUDE.md and AGENTS.md, only CLAUDE.md is read by default (AGENTS.md has been read directly only since 2.1.277). Labs that also use Codex can add one line, @AGENTS.md, to CLAUDE.md, so both tools share a single set of rules.
| Level | Location | When loaded | What to put there |
|---|---|---|---|
| Organization | macOS /Library/Application Support/ClaudeCode/CLAUDE.md; Linux /etc/claude-code/CLAUDE.md | At startup | Rules distributed centrally by administrators |
| User | ~/.claude/CLAUDE.md | At startup, for all projects | Personal habits: reply language, code style |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md | At startup | Directory conventions, run commands, statistical conventions; shared with the repository |
| Local | ./CLAUDE.local.md (add to .gitignore) | At startup, after the CLAUDE.md in the same directory | Paths and test data that belong only to you |
| Parent directories | CLAUDE.md at every level above the startup directory | At startup | Conventions shared by several projects |
| Subdirectories | CLAUDE.md below the startup directory | Loaded when Claude reads or writes files in that subdirectory | Rules that apply only to a particular submodule |
| Path rules | .claude/rules/*.md, with paths in the frontmatter | Loaded when a matching file is read or written | Rules that apply only to R scripts or only to notebooks |
Reference
Rules that sit on top of the permission mode are written in the permissions section of settings.json, in three categories: allow, ask and deny.
Evaluation order
Deny is checked first, then ask, then allow. The first match stops the evaluation, regardless of how specific each pattern is. A deny for Bash(git *) blocks an allow for Bash(git status). Lists with the same name in multiple settings files are merged rather than overwriting each other.
Wildcard placement
Put * after the subcommand. Bash(git log *) allows only git log; Bash(git *) allows every git subcommand, including git -c, which can run arbitrary programs. Bash(ls *) does not match lsof, while Bash(ls*) does.
Path syntax
In Edit(/data/**), a single leading slash is relative to the project containing the settings file; for an absolute path, write //home/me/data/**; for the home directory, write ~/. A /secrets/** path written in user-level settings refers to ~/.claude/secrets. Path rules of the form Write(...) and NotebookEdit(...) are accepted but never take effect; write them as Edit(...) instead.
Settings that can only go in user-level settings
When defaultMode is set to auto or bypassPermissions, placing it in the project .claude/settings.json or settings.local.json has no effect; put it in ~/.claude/settings.json or pass --permission-mode. Tested on this page: claude doctor does not report an error for this placement.
Reference
Several older methods no longer work: claude config set was deprecated in 1.0.7 and removed in 2.0.0; use settings.json or /config instead (the subcommand list in 2.1.296 tested on this page does not include config). Quickly writing to memory with a leading # was removed in 2.0.70. /vim was removed in 2.1.92; set the editor mode in the Editor mode option of /config instead. npm update -g may stay on an older version; to upgrade, use npm install -g @anthropic-ai/claude-code@latest.
| Command or key | Function | Key points |
|---|---|---|
| /init | Generate a draft project CLAUDE.md | If a file already exists, it only suggests changes |
| /context | Show context usage as a grid | See how much Memory files, MCP tools and the conversation each take |
| /compact [focus] | Summarize the conversation to free context | Add a focus, for example /compact keep the parameter table and the last error |
| /clear [name] | Start a new conversation | No cost; earlier conversations can be recovered with /resume |
| /resume, /rename | Resume and name sessions | Name the session before /clear so it can be resumed by name later |
| /rewind (Esc Esc) | Return to an earlier message and optionally roll back code | Does not roll back changes made by Bash commands |
| /model, /effort | Switch the model and the reasoning effort | /model is saved as the default model for new sessions |
| /permissions, /config, /status | Manage rules and settings; check account and gateway | /status is the first step when troubleshooting login and gateway problems |
| /usage | Usage and cost | /cost and /stats are aliases |
| /memory, /hooks, /mcp, /skills | Manage the corresponding extensions | The /agents wizard was removed in 2.1.198; ask Claude to create subagents or edit .claude/agents/ directly |
| /export [filename] | Export the current conversation as plain text | Used to save a process record |
| /doctor | Configuration check inside the session | /doctor prompt-audit checks CLAUDE.md for conflicts and outdated content |
| Shift+Tab | Cycle through permission modes | Some Windows terminals use Alt+M |
| Esc | Interrupt the current reply or tool call | Completed work is kept |
| Ctrl+O | Open the full transcript view | View details of each tool call and the model used |
| Ctrl+B | Move a running command or subagent to the background | Press twice in tmux |
| Ctrl+G | Edit the prompt or plan in an external editor | Suitable for writing long instructions |
| Starts with ! | Run a shell command directly; output enters the conversation | For example !nvidia-smi |
| Starts with @ | Reference a file path | With autocomplete |
| \ + Enter or Ctrl+J | Insert a newline | Works in all terminals |
Reference
- claude --version is not lower than the version your dependencies require; on a cluster, the binary is on a local disk
- /status shows the account or gateway you expect, with no leftover ANTHROPIC_API_KEY
- A CLAUDE.md is in the project root, specifying directory conventions, run commands, random seeds and statistical conventions, under 200 lines
- data/raw has been set with chmod -R a-w, and settings.json has a deny rule for Edit(data/raw/**)
- Operations that need confirmation (git push, installing dependencies) are written as ask rules, and bypassPermissions is not used
- cleanupPeriodDays has been raised, the logs/ directory exists, and key sessions are saved with /export
- Batch scripts use --permission-mode dontAsk, an --allowedTools allowlist, < /dev/null and --max-budget-usd, and claude has been run interactively once in that directory
- Long tasks are started with nohup or sbatch, and Claude is only responsible for reading the logs
Troubleshooting
Troubleshooting order: run claude --version to confirm the version; run claude doctor to check the installation and settings files; run /status inside a session to confirm the account, gateway and active configuration file; if you still cannot locate the problem, start claude with --debug, and the logs are under ~/.claude/debug/; if you suspect custom configuration is the cause, start claude with --safe-mode to compare. The entries below are sorted by frequency. "Experience posts" come from practical write-ups on CSDN and the Alibaba Cloud developer community. They have been checked against the official documentation or the tests on this page, and places that need correction are marked.
Not logged in · Please run /login
Cause: No usable credential is available.
Fix: Run /login, or set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN.
Unable to connect to API (ECONNREFUSED / ENOTFOUND / ERR_PROXY_TUNNEL)
Cause: The network is unreachable, a proxy is not set, or ANTHROPIC_BASE_URL still holds an address that is no longer valid.
Fix: Check each of the following in turn. On WSL, also check /etc/resolv.conf.
curl -I https://api.anthropic.com
echo $ANTHROPIC_BASE_URLcommand not found: claude / 'claude' is not recognized
Cause: The installation directory is not on PATH, or you are still in a terminal that was opened before installation.
Fix: Open a new terminal, and add ~/.local/bin (on Windows, %USERPROFILE%\.local\bin) to PATH.
You've hit your session limit · resets 3:45pm
Cause: The subscription quota has been used up.
Fix: Wait for the reset; check with /usage. If the Opus or Sonnet quota alone is used up, switch to the other model family with /model.
Context limit reached · /compact or /clear to continue
Cause: The conversation plus attachments exceed the context window.
Fix: Use /compact and specify what to keep; use /clear if you do not need the old conversation.
Autocompact is thrashing
Cause: A large file or large output fills the context again right after compaction. This is common when Claude reads a large CSV in full. Claude Code stops retrying.
Fix: Read in segments, using head, wc -l, the nrows option in pandas or df.info() to inspect structure. Hand the processing of large files to a subagent so it runs in that subagent's independent context. Discard large outputs when compacting with /compact.
Subscription login works normally, but requests fail with an authentication error
Cause: An expired ANTHROPIC_API_KEY is left in the shell. Its priority is higher than browser login.
Fix: Run unset ANTHROPIC_API_KEY, then use /status to confirm that the session is back on the subscription.
curl works, but claude still asks for login
Cause: The credentials are written in the project's .claude/settings.json. An interactive session must pass the first-run wizard and the trust dialog before it reads the env in that file.
Fix: Move env to ~/.claude/settings.json, or export the variables in the shell that starts claude.
401 invalid token
Cause: ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer, and ANTHROPIC_API_KEY is sent as x-api-key. A gateway accepts only one of these.
Fix: Switch to the other variable name. Do not set both at the same time.
Startup warns about two credential sources: auth may not work as expected
Cause: Gateway variables and a saved login exist at the same time.
Fix: To use the gateway, run /logout; to use the subscription, unset the gateway variables.
400 Extra inputs are not permitted or context_management
Cause: The upstream does not accept pre-release fields that Claude Code sends.
Fix: Add CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 to env.
400 Input tag 'adaptive' or thinking type should be enabled or disabled
Cause: The upstream model does not support adaptive thinking.
Fix: The official variable CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1 applies only to Opus 4.6 and Sonnet 4.6; for other models, the gateway operator needs to upgrade the upstream. Experience post: an Alibaba Cloud community article writes the variable in lowercase, but environment variable names are case-sensitive and must be fully uppercase.
400 ContextWindowExceededError or prompt token count exceeds the limit
Cause: The gateway's context window is smaller than Claude Code assumes, and the error is rewritten so that automatic compaction is not triggered.
Fix: Use /compact first. Then set CLAUDE_CODE_MAX_CONTEXT_TOKENS or CLAUDE_CODE_AUTO_COMPACT_WINDOW, writing a plain integer: 500k would be read as 500.
The models offered by the gateway do not appear in /model
Cause: The model names are not in the built-in list.
Fix: Set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1, or map model names with variables such as ANTHROPIC_DEFAULT_SONNET_MODEL.
No response for a long time, then Connection refused (ECONNREFUSED)
Cause: The address is wrong or the gateway has stopped. Claude Code retries 10 times by default, so it takes a long time before reporting the error.
Fix: Tested on this page: by default the error appears after 2 minutes 56 seconds; with CLAUDE_CODE_MAX_RETRIES=0 it appears after 5.9 seconds. Remove this variable again after troubleshooting.
Still cannot connect after setting a proxy
Cause: Claude Code does not support SOCKS proxies.
Fix: Point HTTPS_PROXY at the HTTP port of your proxy software, for example http://127.0.0.1:<HTTP port>.
SSL certificate verification failed, but curl works
Cause: The Claude Code runtime does not trust the root certificate of your company or proxy software.
Fix: Set NODE_EXTRA_CA_CERTIFICATE to point to the CA certificate file.
First run is stuck at Unable to connect to Anthropic services, or shows Failed to connect to api.anthropic.com: ERR_BAD_REQUEST
Cause: When using a relay, the first-run wizard probes api.anthropic.com and platform.claude.com, and a failed probe causes it to hang. Three authors of experience posts independently reported this (March–June 2026).
Fix: The experience posts suggest adding "hasCompletedOnboarding": true to ~/.claude.json, then continuing. Note: add this key with an editor. Do not overwrite the whole file with cat > ~/.claude.json, because that file also stores project trust, OAuth and personal MCP server settings. Writing it into settings.json has no effect, and claude doctor does not report anything for it in tests on this page.
"hasCompletedOnboarding": trueClaude Code on Windows requires git-bash (older versions)
Cause: Older versions require Git Bash. A CSDN author using Windows encountered this error.
Fix: Set CLAUDE_CODE_GIT_BASH_PATH to the path of bash.exe; the experience post reports this solved the problem. Current versions fall back to PowerShell when Git for Windows is not installed, and the error becomes the next entry.
Claude Code on Windows requires either Git for Windows (for bash) or PowerShell
Cause: Neither shell can be found.
Fix: Install Git for Windows, or set CLAUDE_CODE_GIT_BASH_PATH.
A file named nul appears in the working directory
Cause: Early versions wrote the Unix /dev/null redirection on Windows and created this file (GitHub #4928).
Fix: Upgrade to the latest version. If the nul file that was already created cannot be deleted in Explorer, delete it in Git Bash with rm ./nul.
The token '&&' is not a valid statement separator, or 'irm' is not recognized
Cause: The first means a CMD command was run in PowerShell; the second means a PowerShell command was run in CMD.
Fix: If the prompt starts with PS, you are in PowerShell; run the command intended for it.
exec: node: not found, or platform mismatch
Cause: The output of which node starts with /mnt/c/, which means WSL is using the Node installed on Windows.
Fix: Run npm config set os linux, or install Node inside WSL with nvm. Switching to the native install script avoids this kind of problem.
Bus error / oh no: Bun has crashed
Cause: A running executable was deleted or truncated. This is common with an NFS-shared home directory: another node upgraded in place with npm and deleted the old binary.
Fix: Install the binary on a local disk; or set DISABLE_UPDATES and have an administrator upgrade it centrally.
Killed (during installation on Linux)
Cause: Insufficient memory.
Fix: The official minimum is 4 GB of memory. Free up memory or add swap, then reinstall.
syntax error near unexpected token '<'
Cause: The install address returns a web page instead of a script. This is common with network routing or regional restrictions.
Fix: Try again later, or use brew or winget instead. If the output contains App unavailable in region, your region is not on the supported list.
curl: (22) ... error: 403
Cause: A proxy or firewall blocked the download, or there is a regional restriction.
Fix: Check connectivity to downloads.claude.ai and your proxy settings.
OAuth error: Invalid code
Cause: The login code has expired, or it was copied incompletely.
Fix: Run /login again, and paste the code as soon as possible after opening the browser.
API Error: 403 Request not allowed
Cause: The subscription is not active, the Console account lacks the Claude Code role, or a proxy is interfering.
Fix: Check the subscription status at claude.ai/settings. For a Console account, ask an administrator to assign the Developer or Claude Code role.
Claude Opus is not available with the Claude Pro plan
Cause: The plan does not include the selected model, or the token was not refreshed after an upgrade.
Fix: Switch models with /model. If you just upgraded your plan, run /logout and then /login.
--dangerously-skip-permissions cannot be used with root/sudo privileges
Cause: Bypass mode was run as root.
Fix: Run as a regular user, or run inside the official dev container.
A file in the working directory was deleted by rm without a confirmation prompt
Cause: acceptEdits automatically approves rm inside the working directory. Checkpoints roll back only changes made by editing tools; they do not track files deleted by Bash.
Fix: Set raw data to read-only with chmod -R a-w, and add rules such as Bash(rm -rf *) to deny. Checkpoints cannot roll back files deleted by Bash.
data/raw is still written by a Python or R script, and the deny rule did not block it
Cause: Read and Edit rules do not apply to open() or write.csv() inside scripts. See "What deny rules cover and what they do not".
Fix: Protect with operating-system-level chmod -R a-w data/raw, and add a PreToolUse hook that blocks writes (see What each extension mechanism does).
CLAUDE.md has the rule, but Claude does not follow it
Cause: CLAUDE.md is context, not enforced configuration. The file may not have loaded, or there are contradictory requirements across levels.
Fix: Run /context to confirm the file is loaded, and check the levels for contradictions. Rewrite restrictions that must be enforced as ask or deny rules in settings.json, or as PreToolUse hooks.
Setting defaultMode to auto in the project .claude/settings.json has no effect
Cause: When defaultMode is set to auto or bypassPermissions, it takes effect only in user-level settings. Placing it in project settings has no effect, and claude doctor does not report an error.
Fix: Write it in ~/.claude/settings.json, or specify it at startup with the --permission-mode flag.
claude -p prints Ignoring 4 permissions.allow entries from .claude/settings.json: this project has not been trusted
Cause: In an untrusted directory, all allow rules in the project settings are ignored. The env in the same file still applies.
Fix: Run claude once in that directory first, and accept the trust dialog.
Warning: no stdin data received in 3s
Cause: When stdin is not a terminal, claude -p waits for 3 seconds.
Fix: Add < /dev/null in the script.
Rules in settings seem to have no effect in a batch run, and no error is shown
Cause: In -p mode, a settings file that fails validation is silently ignored.
Fix: Run claude doctor to check the settings files before batch processing.
The session created by claude -p cannot be found in the claude --resume list
Cause: Sessions created by claude -p do not appear in the list, and claude --continue does not select them.
Fix: Continue with the session_id returned by --output-format json, using claude --resume <id>.
After resuming a session, flags such as --add-dir and --mcp-config have no effect
Cause: When resuming a session, these startup flags are not carried over automatically and must be passed again.
Fix: Pass these flags again when resuming.
A subagent does not appear in the list, and no warning is shown
Cause: The frontmatter is missing name or description, the YAML cannot be parsed, or the opening --- is not on the first line; the file is then silently skipped.
Fix: Check with claude plugin validate .claude/agents, then view the log with claude --debug.
claude mcp list shows Pending approval
Cause: In the .mcp.json file in the project root, shared MCP servers must be approved by each member the first time.
Fix: Approve the server when prompted inside claude.
Sources
- Claude Code Docs: Advanced setup — Installation routes, automatic updates, Node version requirements for npm, Bus error on NFS, comparison of native Windows and WSL
- Claude Code Docs: Authentication — Account types, credential priority, where credentials are stored, setup-token
- Claude Code Docs: Connect Claude Code to an LLM gateway — How to write ANTHROPIC_BASE_URL and credential variables, curl verification, gateway failure table
- Claude Code Docs: Environment variables — Meaning and default values of variables for timeouts, retries, context window and model mapping
- Claude Code Docs: Network configuration — HTTPS_PROXY, lack of SOCKS support, domains that must be allowed
- Claude Code Docs: How Claude remembers your project — CLAUDE.md levels, loading order, @ imports, AGENTS.md, length guidance
- Claude Code Docs: Choose a permission mode — Six modes, auto as the default starting mode, protected paths and critical paths
- Claude Code Docs: Configure permissions — Rule evaluation order, wildcards, path syntax, scope of Read/Edit rules
- Claude Code Docs: Settings files and precedence — Scope and precedence of the four settings files; values that can only be set at user level
- Claude Code Docs: Commands and Interactive mode — Slash commands and keyboard shortcuts; removed commands
- Claude Code Docs: Create custom subagents — Subagent file format and cases where files are silently skipped
- Claude Code Docs: Automate actions with hooks — PreToolUse blocking scripts; relationship between hooks and permission modes
- Claude Code Docs: Run Claude Code programmatically — claude -p, output formats, waiting for background tasks, unattended parameters
- Claude Code Docs: Manage sessions — --resume and --continue, session record location and 30-day retention
- Claude Code Docs: Tools reference — Bash timeouts, time limits for background commands, output limits, environment activation
- Claude Code Docs: Explore the context window — Content kept and lost after compaction
- Claude Code Docs: Manage costs effectively — Average spending, cache lifetime, reasons usage rises in long sessions
- Claude Code Docs: Troubleshoot installation and login, and Error reference — Original error text and how to handle it
- Claude Code Docs: Changelog — Versions in which commands such as claude config, the /agents wizard and # quick memory were removed
- Claude pricing page — Prices for Free, Pro and Max, and whether Claude Code is included
- Claude API Pricing — Price per million tokens for each model
- GitHub anthropics/claude-code #12507 — Exits immediately on HPC compute nodes; fixed in 2.1.76
- GitHub anthropics/claude-code #4928 — nul file created on Windows
- GitHub anthropics/claude-code #2544 — Enforced rules in CLAUDE.md are ignored
- Experience post: CSDN, "Solving the Claude Code first-run onboarding not completed problem" — hasCompletedOnboarding and the original error text; two other authors give the same fix
- Experience post: CSDN, "Configuring Claude Code on a remote server without root" — Deployment approach for servers without root; the retired model and the approach of overwriting ~/.claude.json in the post need correction
- Experience post: CSDN, "claude --version error requires git-bash" — Setting CLAUDE_CODE_GIT_BASH_PATH on Windows
- Experience post: Alibaba Cloud Developer Community, "Installing Claude Code in China" — Adaptive thinking error with third-party models; variable name case needs correction