Claude Code is making waves as a next-generation AI coding assistant. It handles code generation, debugging, and optimization with impressive capability. If you're wondering how to squeeze more productivity out of this tool, you're in the right place. Let me walk you through some practical techniques that actually work.
First things first—you'll need Node.js 18 or higher. The installation is straightforward:
bash
npm install -g @anthropic-ai/claude-code
Once installed, you have two main authentication options:
For Claude Pro or Max subscribers: Simply type claude in your terminal and follow the login prompts.
For API key holders: Set up your environment variable:
bash
export ANTHROPIC_AUTH_TOKEN=sk-your-api-key
When working with AI development tools, having reliable infrastructure matters. If you're looking for stable code generation and testing environments, 👉 explore AICodeMirror's intelligent coding platform that supports multiple AI models with seamless integration.
Claude Code doesn't lock you into a single model provider. You can connect to various AI services:
Alibaba Cloud (Dashscope):
bash
echo 'export ANTHROPIC_BASE_URL="https://dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="YOUR_DASHSCOPE_API_KEY"' >> ~/.zshrc
source ~/.zshrc
Moonshot (Kimi):
bash
export ANTHROPIC_BASE_URL=https://api.moonshot.cn/anthropic
export ANTHROPIC_AUTH_TOKEN=${YOUR_MOONSHOT_API_KEY}
export ANTHROPIC_MODEL=kimi-k2-turbo-preview
export ANTHROPIC_SMALL_FAST_MODEL=kimi-k2-turbo-preview
claude
Here's where things get interesting. Claude Code Router (CCR) acts as an intelligent traffic controller for your AI requests. Instead of being stuck with one model, you can route different tasks to different AI providers based on what they do best.
Installation:
bash
npm install -g @musistudio/claude-code-router
What makes CCR special:
Multi-model support: Connect to OpenRouter, DeepSeek, Ollama (local models), Google Gemini, and more.
Smart task routing: CCR automatically selects the right model based on task type:
default: Everyday coding tasks
background: Low-priority, non-urgent operations with cost-effective models
think: Complex logic requiring deep reasoning
longContext: Triggered when your input exceeds 60,000 tokens (think massive codebases)
webSearch: Tasks requiring internet access
Request/response transformation: Different AI models speak different API languages. CCR's built-in transformers handle these differences automatically. Some transformers add extra capabilities:
tooluse: Optimizes function calling for specific models
maxtoken: Forces a specific token limit
reasoning: Handles model-specific reasoning fields
enhancetool: Adds error tolerance to tool calls
Edit ~/.claude-code-router/config.json to set up your preferences. Here's a basic structure:
json
{
"APIKEY": "your-secret-key",
"PROXY_URL": "http://127.0.0.1:7890",
"LOG": true,
"Providers": [
{
"name": "openrouter",
"api_base_url": "https://openrouter.ai/api/v1/chat/completions",
"api_key": "sk-your-openrouter-api-key-here",
"models": [
"google/gemini-2.5-pro-preview",
"anthropic/claude-3.5-sonnet"
],
"transformer": {
"use": ["openrouter"]
}
}
],
"Router": {
"default": "openrouter,anthropic/claude-3.5-sonnet",
"background": "openrouter,google/gemini-2.5-flash",
"think": "openrouter,anthropic/claude-3.5-sonnet",
"longContext": "openrouter,google/gemini-2.5-pro-preview",
"longContextThreshold": 60000,
"webSearch": "openrouter,google/gemini-2.5-flash"
}
}
Cost-saving configuration example:
For daily tasks, use Kimi-k2. For ultra-long conversations or web searches, switch to OpenRouter's Gemini. This hybrid approach balances performance and cost.
Web UI Configuration:
CCR includes a visual configuration interface. Launch it with:
bash
ccr ui
No more manual JSON editing—just fill in your API keys, select models, and set routing rules through a clean interface. Remember to restart CCR after saving changes.
Running CCR:
Start with:
bash
ccr code
Type your coding questions or commands, and CCR routes them to the appropriate model automatically. If something goes wrong, check the logs at ~/.claude-code-router/claude-code-router.log.
For developers managing multiple AI integrations and looking for better cost control, 👉 AICodeMirror offers unified API access to various AI models, simplifying your workflow while optimizing expenses.
1. Project Initialization
Use the /init command for new projects or when you want Claude to deeply understand your codebase. This generates a CLAUDE.md file containing project structure, conventions, and common commands—essentially Claude's "project memory."
2. Direct System Commands
Prefix commands with ! to execute them directly in your terminal without consuming Claude's tokens:
bash
!git status
!npm install
!ls -la
3. Work Modes
Claude Code offers three modes (toggle with Shift + Tab):
Default: Asks for confirmation before each action—safe but slower
Auto-accept: Automatically executes file operations—faster but requires trust
Plan: Creates a detailed plan first, executes after your approval—ideal for complex tasks
4. Session Management
Use claude -c to continue your last conversation
Use claude --resume or /resume within a session to pick up from any previous conversation
5. Cost Control
If you're using token-based API billing, check costs with /cost. Optimize token usage by referencing files with @ and compressing history with /compact.
6. Git Worktrees for Parallel Tasks
Git worktrees let you check out multiple branches from the same repository into different directories. Each worktree has its own working directory and file state while sharing the same Git history. This means you can work on different branches simultaneously without constant branch-switching.
Sub agents in Claude Code are specialized AI assistants for specific task types. They provide task-specific configurations including custom system prompts, tools, and independent context windows for more efficient problem-solving.
Claude Code represents a shift in how we think about coding assistants. It's not just about generating code—it's about intelligent task routing, cost management, and adapting to your specific workflow. Whether you stick with the official setup or dive into CCR's flexible routing system, the key is finding what works for your projects.
Start simple, experiment with different configurations, and gradually build a setup that matches your development style. The tool is powerful, but its real value comes from how you use it.