FAQ
Frequently asked questions about Claude Code
Frequently Asked Questions (FAQ)¶
This document answers common questions about using Claude Code.
Installation & Setup¶
Q: How do I install Claude Code?¶
A: Claude Code is installed globally via npm:
npm install -g @anthropic-ai/claude-code
After installation, run claude in any project directory to start.
Q: The claude command is not found after installation?¶
A: This usually means npm's global directory is not in your PATH. Solution:
# Check npm global directory
npm config get prefix
# Add the bin subdirectory to PATH
# macOS/Linux (add to ~/.zshrc or ~/.bashrc)
export PATH="$(npm config get prefix)/bin:$PATH"
Q: How do I configure QCode.cc proxy?¶
A: Set these environment variables:
export ANTHROPIC_BASE_URL="https://asia.qcode.cc/api"
export ANTHROPIC_AUTH_TOKEN="cr_your_api_key"
We recommend adding these to your shell config file (e.g., ~/.zshrc).
API Key & Authentication¶
Q: Where do I get an API Key?¶
A: Log in to QCode.cc Dashboard and create or view your API Key in the API Key management page.
Q: What prefix does the API Key have?¶
A: QCode.cc API Keys start with cr_, e.g., cr_xxxxxxxxxxxxxx.
Q: Why is my API Key not working?¶
A: Possible reasons:
1. Copy error: Check for extra spaces or missing characters
2. Subscription expired: Check your account subscription status
3. Environment variable not loaded: Reopen terminal or run source ~/.zshrc
4. Wrong API endpoint: Confirm ANTHROPIC_BASE_URL is set correctly
Usage & Costs¶
Q: How do I check current session usage?¶
A: There are two ways to check usage:
Option 1: Dashboard (Recommended)
Log in to QCode.cc Dashboard and check the "Usage Statistics" section:
- Model Call Counts: Usage frequency for each model
- Cost Breakdown: Accurate cost consumption details
- Quota Usage: Current plan quota consumption progress
Dashboard data updates in near real-time, with more accurate billing. We use the industry-standard LiteLLM pricing rules and sync updates regularly to ensure billing accuracy.
Option 2: Quick Check in CLI
Use the /cost command for a quick overview of current session:
/cost
Example output:
Total cost: $0.55
Total duration (API): 6m 19.7s
Total code changes: 10 lines added, 5 lines removed
Note: The cost shown by
/costis for reference only, useful for quickly checking model distribution and approximate usage. Since Anthropic hasn't published detailed pricing rules for each model, the CLI's built-in billing may differ from actual costs. We recommend using Dashboard statistics as the authoritative source.
Q: How can I reduce token consumption?¶
A: Several effective methods:
- Compress context: Use
/compactcommand - Clear history: Use
/clearto reset context - Be specific: Avoid vague questions that cause unnecessary scanning
- Break down tasks: Split large tasks into smaller ones
Q: When does context auto-compact?¶
A: Claude Code auto-compacts by default when context reaches 95% capacity. You can also:
- Manually run /compact to compact proactively
- Add custom instructions after /compact to control what to focus on
Permission System¶
Q: What permission modes are available?¶
A: Four permission modes:
| Mode | Description |
|---|---|
default |
Prompts on first use of each tool |
acceptEdits |
Auto-approves file edits |
plan |
Analyze only, no modifications (Plan Mode) |
bypassPermissions |
Skips all prompts (requires safe environment) |
Q: How do I set a default permission mode?¶
A: Configure in .claude/settings.json:
{
"permissions": {
"defaultMode": "plan"
}
}
Q: How do I prevent Claude from reading sensitive files?¶
A: Configure deny rules in .claude/settings.json:
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
]
}
}
Q: How do I pre-approve common commands?¶
A: Configure allow rules in .claude/settings.json:
{
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run test:*)",
"Bash(git status)"
]
}
}
CLAUDE.md Configuration¶
Q: What is CLAUDE.md?¶
A: CLAUDE.md is a project-level config file that provides project context to Claude, such as: - Project architecture - Coding conventions - Common commands - Special conventions
Q: Where should I put CLAUDE.md?¶
A: Place it in the project root. Claude Code reads it automatically on startup.
Q: How do I create CLAUDE.md?¶
A: Use the /init command to auto-generate:
/init
Or create manually with this basic structure:
# Project Name
## Overview
Brief description of the project...
## Tech Stack
- Frontend: React
- Backend: FastAPI
## Common Commands
- Start dev server: `npm run dev`
- Run tests: `npm test`
## Coding Standards
- Use TypeScript
- Prefer functions over classes
Context Management¶
Q: How do I clear session history?¶
A: Use the /clear command:
/clear
This clears all conversation history and starts a fresh session.
Q: How do I compact without clearing history?¶
A: Use the /compact command:
/compact
You can add instructions to control what to focus on:
/compact Preserve all code examples
Q: How do I check current context status?¶
A: Use the /context command:
/context
Q: How do I use @ to reference files?¶
A: Use @ to directly reference files into context:
@src/main.ts Explain this file
@package.json Check dependency versions
MCP Servers¶
Q: What is MCP?¶
A: MCP (Model Context Protocol) is a protocol that allows Claude Code to connect to external tools and data sources, extending its capabilities.
Q: How do I configure MCP servers?¶
A: Configure in ~/.claude/settings.json:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@context7/mcp-server"]
}
}
}
Q: Why is my MCP server connection failing?¶
A: Check the following:
1. Is the server command correct?
2. Are required dependencies installed?
3. Are environment variables properly set?
4. Use /mcp command to check status
Common Operations¶
Q: How do I enter Plan Mode?¶
A: Press Shift+Tab twice, or set it as default mode in settings. In Plan Mode, Claude analyzes but doesn't execute.
Q: How do I switch models?¶
A: Use the /model command:
/model opus
/model sonnet
Q: How do I see available commands?¶
A: Use /help command to see all built-in commands.
Q: How do I interrupt a running operation?¶
A: Press Escape to interrupt the current operation.
Q: How do I make Claude remember certain information?¶
A: Use the /memory command to add to session memory:
/memory This project uses pnpm instead of npm
Git Operations¶
Q: How do I get Claude to commit code?¶
A: Use the /commit command:
/commit
Claude will analyze changes and generate a commit message.
Q: How do I get Claude to review code?¶
A: Use the /review command:
/review
You can specify a scope:
/review src/auth/
Troubleshooting¶
Q: Claude is responding slowly?¶
A: Try these methods:
1. Check network connection
2. Use /compact to compress context
3. Avoid peak hours
4. Check if large files are in context
Q: Getting "Rate limit exceeded"?¶
A: This is a 429 error indicating too many requests: 1. Wait 30-60 seconds before retrying 2. Reduce request frequency 3. See Error Code Reference for details
Q: Claude can't read a file?¶
A: Check: 1. Does the file exist? 2. Are file permissions correct? 3. Is the file in a deny rule? 4. Is the path correct?
Q: How do I report a bug?¶
A: 1. Visit GitHub Issues 2. Provide detailed reproduction steps 3. Include relevant error messages
More Help¶
If your question isn't answered here:
- Official docs: Claude Code Documentation
- QCode.cc support: Live chat at bottom right of website
- Community: GitHub Discussions