claude-code-guide

Original🇨🇳 Chinese
Translated

Claude Code Advanced Development Guide - A comprehensive tutorial covering tool usage, REPL environment, development workflows, MCP integration, advanced patterns, and best practices. Ideal for learning Claude Code's advanced features and development techniques.

23installs
Added on

NPX Install

npx skill4agent add 2025emma/vibe-coding-cn claude-code-guide

SKILL.md Content (Chinese)

View Translation Comparison →

Claude Code Advanced Development Guide

A comprehensive learning guide for Claude Code, covering all core concepts from basics to advanced levels, tool usage, development workflows, and best practices.

When to Use This Skill

Use this skill when you need help with:
  • Learning Claude Code's core features and tools
  • Mastering advanced usage of the REPL environment
  • Understanding development workflows and task management
  • Integrating external systems using MCP
  • Implementing advanced development patterns
  • Applying Claude Code best practices
  • Resolving common issues and errors
  • Performing large file analysis and processing

Quick Reference

Claude Code Core Tools (7)

  1. REPL - JavaScript runtime environment
    • Full ES6+ support
    • Preloaded libraries: D3.js, MathJS, Lodash, Papaparse, SheetJS
    • Supports async/await, BigInt, WebAssembly
    • File reading:
      window.fs.readFile()
  2. Artifacts - Visual output
    • React, Three.js, chart libraries
    • HTML/SVG rendering
    • Interactive components
  3. Web Search - Web search
    • US-only availability
    • Domain filtering support
  4. Web Fetch - Retrieve web content
    • HTML to Markdown conversion
    • Content extraction and analysis
  5. Conversation Search - Conversation search
    • Search historical conversations
    • Context retrieval
  6. Recent Chats - Recent conversations
    • Access recent sessions
    • Conversation history
  7. End Conversation - End conversation
    • Cleanup and summary
    • Session management

Large File Analysis Workflow

bash
# Phase 1: Quantitative Assessment
wc -l filename.md    # Line count
wc -w filename.md    # Word count
wc -c filename.md    # Character count

# Phase 2: Structural Analysis
grep "^#{1,6} " filename.md  # Extract heading hierarchy
grep "```" filename.md       # Identify code blocks
grep -c "keyword" filename.md # Keyword frequency

# Phase 3: Content Extraction
Read filename.md offset=0 limit=50      # File start
Read filename.md offset=N limit=100     # Target section
Read filename.md offset=-50 limit=50    # File end

Advanced REPL Usage

javascript
// Data processing
const data = [1, 2, 3, 4, 5];
const sum = data.reduce((a, b) => a + b, 0);

// Use preloaded libraries
// Lodash
_.chunk([1, 2, 3, 4], 2);  // [[1,2], [3,4]]

// MathJS
math.sqrt(16);  // 4

// D3.js
d3.range(10);  // [0,1,2,3,4,5,6,7,8,9]

// Read file
const content = await window.fs.readFile('path/to/file');

// Async operation
const result = await fetch('https://api.example.com/data');
const json = await result.json();

Slash Command System

Built-in Commands:
  • /help
    - Show help
  • /clear
    - Clear conversation
  • /plugin
    - Manage plugins
  • /settings
    - Configure settings
Custom Commands: Create
.claude/commands/mycommand.md
:
markdown
Instructions to perform specific tasks based on requirements
Usage:
/mycommand

Development Workflow Patterns

1. File Analysis Workflow

bash
# Explore → Understand → Implement
ls -la                  # List files
Read file.py            # Read content
grep "function" file.py # Search patterns
# Then implement modifications

2. Algorithm Validation Workflow

bash
# Design → Validate → Implement
# 1. Test logic in REPL
# 2. Verify edge cases
# 3. Implement into code

3. Data Exploration Workflow

bash
# Inspect → Analyze → Visualize
# 1. Read data file
# 2. Analyze in REPL
# 3. Visualize with Artifacts

Core Concepts

Tool Permission System

Tools with Auto-Granted Permissions:
  • REPL
  • Artifacts
  • Web Search/Fetch
  • Conversation Search
Tools Requiring Authorization:
  • Bash (read/write file system)
  • Edit (modify files)
  • Write (create files)

Project Context

Claude automatically identifies:
  • Git repository status
  • Programming languages (from file extensions)
  • Project structure
  • Dependency configurations

Memory System

Conversation Memory:
  • Stored in current session
  • 200K token window
  • Automatic context management
Persistent Memory (Experimental):
  • Saved across sessions
  • User preference memory
  • Project context retention

MCP Integration

What is MCP?

Model Context Protocol - A protocol for connecting Claude to external systems.

MCP Server Configuration

Configuration file:
~/.config/claude/mcp_config.json
json
{
  "mcpServers": {
    "my-server": {
      "command": "node",
      "args": ["path/to/server.js"],
      "env": {
        "API_KEY": "your-key"
      }
    }
  }
}

Using MCP Tools

Claude automatically discovers MCP tools and uses them in conversations:
"Use the my-server tool to retrieve data"

Hook System

Hook Types

Configure in
.claude/settings.json
:
json
{
  "hooks": {
    "tool-pre-use": "echo 'About to use tool'",
    "tool-post-use": "echo 'Tool used'",
    "user-prompt-submit": "echo 'Processing prompt'"
  }
}

Common Hook Use Cases

  • Automatic code formatting
  • Run tests
  • Git commit checks
  • Logging
  • Notification sending

Advanced Patterns

Multi-Agent Collaboration

Use the Task tool to start sub-agents:
"Start a specialized agent to optimize this algorithm"
Sub-agent features:
  • Independent context
  • Focused on single task
  • Returns results to main agent

Intelligent Task Management

Use the TodoWrite tool:
"Create a task list to track this project"
Task statuses:
  • pending
    - Pending
  • in_progress
    - In progress
  • completed
    - Completed

Code Generation Patterns

Incremental Development:
  1. Generate basic structure
  2. Add core functionality
  3. Implement details
  4. Test and optimize
Validation-Driven:
  1. Write test cases
  2. Implement functionality
  3. Run tests
  4. Fix issues

Quality Assurance

Automated Testing

bash
# Run tests
npm test
pytest

# Type checking
mypy script.py
tsc --noEmit

# Code linting
eslint src/
flake8 .

Code Review Pattern

Use sub-agents for review:
"Start a code review agent to check this file"
Review focus areas:
  • Code quality
  • Security issues
  • Performance optimization
  • Best practices

Error Recovery

Common Error Patterns

  1. Tool Usage Errors
    • Check permissions
    • Validate syntax
    • Confirm paths
  2. File Operation Errors
    • Verify file exists
    • Check read/write permissions
    • Validate path correctness
  3. API Call Errors
    • Check network connection
    • Verify API key
    • Confirm request format

Incremental Fix Strategy

  1. Isolate the problem
  2. Minimize reproduction
  3. Fix incrementally
  4. Validate solution

Best Practices

Development Principles

  1. Clarity First - Clearly define requirements and goals
  2. Incremental Implementation - Develop in stages
  3. Continuous Validation - Test frequently
  4. Appropriate Abstraction - Reasonable modularization

Tool Usage Principles

  1. Right Tool for the Job - Choose appropriate tools
  2. Tool Combination - Collaborate with multiple tools
  3. Least Privilege - Request only necessary permissions
  4. Error Handling - Gracefully handle failures

Performance Optimization

  1. Batch Operations - Combine multiple operations
  2. Incremental Processing - Handle large files
  3. Cache Results - Avoid redundant calculations
  4. Async First - Use async/await

Security Considerations

Sandbox Model

Each tool runs in an isolated environment:
  • REPL: No file system access
  • Bash: Requires explicit authorization
  • Web: Only specific domains

Security Best Practices

  1. Least Privilege - Grant only necessary permissions
  2. Code Review - Inspect generated code
  3. Sensitive Data - Do not share keys
  4. Regular Audits - Check hooks and configurations

Troubleshooting

Tool Unavailable

Symptom: Tool call fails
Solutions:
  • Check permission settings
  • Validate syntax correctness
  • Confirm file paths
  • Review error messages

REPL Performance Issues

Symptom: REPL execution is slow
Solutions:
  • Reduce data volume
  • Use streaming processing
  • Optimize algorithms
  • Process in batches

MCP Connection Failure

Symptom: MCP server unresponsive
Solutions:
  • Check configuration files
  • Verify server is running
  • Confirm environment variables
  • Review server logs

Practical Examples

Example 1: Data Analysis

javascript
// In REPL
const data = await window.fs.readFile('data.csv');
const parsed = Papa.parse(data, { header: true });
const values = parsed.data.map(row => parseFloat(row.value));
const avg = _.mean(values);
const std = math.std(values);
console.log(`Average: ${avg}, Standard Deviation: ${std}`);

Example 2: File Search

bash
# In Bash
grep -r "TODO" src/
find . -name "*.py" -type f

Example 3: Web Data Retrieval

"Use web_fetch to get content from https://api.example.com/data, then analyze the JSON data in REPL"

Reference Files

This skill includes detailed documentation:
  • README.md (9,594 lines) - Complete Claude Code Advanced Guide
Covers the following topics:
  • In-depth analysis of core tools
  • Advanced REPL collaboration patterns
  • Detailed development workflows
  • Complete MCP integration guide
  • Hook system configuration
  • Advanced patterns and best practices
  • Troubleshooting and security considerations
Use the
view
command to access reference files for detailed information.

Resources

Notes

This guide combines:
  • Official features and announcements
  • Patterns observed in practical usage
  • Conceptual approaches and best practices
  • Third-party tool integrations
Please refer to the latest official documentation when using.

Use this skill to master the powerful features of Claude Code!