Claude Code
Configuration
~/.claude/settings.json:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "<YOUR_API_KEY>",
"ANTHROPIC_BASE_URL": "https://open.bigmodel.cn/api/anthropic",
"ANTHROPIC_MODEL": "glm-4.7",
"ANTHROPIC_SMALL_FAST_MODEL": "glm-4.7",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.7",
"API_TIMEOUT_MS": "3000000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
Memory
Captures everything Claude does during your coding sessions, compresses it with Claude agent-sdk,
and injects relevant context back into future sessions.
Session
Resume from session:
# Most recent session
claude -c
# Specific session
claude -r
claude -r [session_id]
Non-interactive Mode
Use Claude Code as a unix-style utility:
claude -p "$REVIEW_PROMPT" > review-result.md 2>&1 || true
See GitHub code review action, improved version, and agent-native version.
Composable
Unix 系统中, 命令行工具通常是独立的、可组合的,
claude -p 可以接受标准输入, 并且可以与其他工具无缝集成,
从而形成一个强大的工具链.
Commands
.claude/commands/api/api-new.md:
Create a new POST $ARGUMENTS endpoint with:
- Auth middleware.
- Rate limiting middleware.
- Error handling wrapper.
- TypeScript interfaces for request and response.
/api-new /api/users
Skills
<skills_instructions>
When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively.
How to use skills:
- Invoke skills using this tool with the skill name only (no arguments)
- When you invoke a skill, you will see <command-message>The "{name}" skill is loading</command-message>
- The skill's prompt will expand and provide detailed instructions
Important:
- Only use skills listed in <available_skills> below
- Do not invoke a skill that is already running
</skills_instructions>
<available_skills>
<skill>
<name>xlsx</name>
<description>Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis...</description>
<location>plugin</location>
</skill>
</available_skills>
渐进式披露:
- 核心功能简洁: 500 行以内.
- 高级功能分离.
- 按需加载: metadata -> instructions -> resources and code.
工具选择
- 临时任务 -> prompts
- 标准作业程序 -> skills
- 连接外部系统 -> MCP
- 复杂独立任务 -> sub-agents
Name
Using gerund form verb + -ing:
this clearly describes activity or capability:
processing-pdfanalyzing-spreadsheetsmanaging-databasestesting-codewriting-documentation
Description
核心原则: 既要说明做什么,也要说明什么时候用:
description: Extract text and tables from PDF files, fill forms, merge documents.
Use when working with PDF files or when the user mentions PDFs,
forms, or document extraction.
Effective
- Core quality:
- Description is specific and includes key terms
- Description includes both what the Skill does and when to use it
- SKILL.md body is under 500 lines
- Additional details are in separate files (if needed)
- No time-sensitive information (or in "old patterns" section)
- Consistent terminology throughout
- Examples are concrete, not abstract
- File references are one level deep
- Progressive disclosure used appropriately
- Workflows have clear steps
- Code and scripts:
- Scripts solve problems rather than punt to Claude
- Error handling is explicit and helpful
- No "voodoo constants" (all values justified)
- Required packages listed in instructions and verified as available
- Scripts have clear documentation
- No Windows-style paths (all forward slashes)
- Validation/verification steps for critical operations
- Feedback loops included for quality-critical tasks
- Testing:
- At least three evaluations created
- Tested with Haiku, Sonnet, and Opus
- Tested with real usage scenarios
- Team feedback incorporated (if applicable)
Security
- Code Review:
- 所有脚本已审查
- 无硬编码密钥或密码
- 无危险的系统命令(rm -rf, eval, exec)
- 文件路径经过验证(防止路径遍历)
- Network Access:
- 检查所有外部 URL
- 验证 API 端点可信
- 处理网络失败情况
- Data Handling:
- 无敏感数据泄露
- 日志不包含 PII
- 临时文件正确清理
- Permissions:
- 最小权限原则
- 不请求不必要的文件访问
- 明确说明需要的权限
- Documentation:
- 安全注意事项已文档化
- 数据处理流程透明
- 用户知情同意
grep -r "requests\." .
grep -r "os.system" .
grep -r "subprocess" .
grep -r "eval" .
Plugins
Install plugins from marketplace, it will extend Claude Code through the plugin system with:
- Custom commands.
- Agents.
- Hooks.
- Skills.
- MCP servers.
/plugin marketplace add anthropics/claude-plugins-official
/plugin marketplace add obra/superpowers-marketplace
/plugin marketplace add sabertazimi/claude-code
/plugin install frontend-design
/plugin install ralph-wiggum
/plugin install superpowers@superpowers-marketplace
/plugin install sabertaz-claude-code
SDK
Best Practices
Claude code best practices:
- Plan mode: 对于复杂的任务, 使用 plan mode 先进行规划, 会比直接执行更高效.
- Extended thinking mode:
MAX_THINKING_TOKENS. - Claude code has built-in toolkit, follow certain paradigm to use them.
- Avoid
/compact: dump plan and progress +/clearthe state + restart from dump file. - Use Claude Code GitHub Actions.
Library
Boilerplate
- Switch: Quick configuration with All-in-One assistant.
- Bootstrap: Opinionated project initialization.
- Showcase: Comprehensive Claude Code project configuration.
- Seekers: Convert documentation websites, GitHub repositories, and PDFs into Claude AI skills with automatic conflict detection.
Workflow
- Superpowers: Complete software development workflow.
- Agents: Comprehensive production-ready system combining agents, multi-agent workflow orchestrators, skills, and slash commands.
- Manus: Manus-style persistent markdown planning.
- Ralph: Autonomous development loop.
- Compound: Compound engineering plugin.
- Continuous: Session continuity, token-efficient MCP execution, and agentic workflows.
Frontend
- Vercel: React best practices and web design guidelines.
- Expo: Skills for Expo projects and application services.
- UI/UX: Provide design intelligence for building professional UI/UX multiple platforms.
- Edmuds: Personal configuration for productive web development.
Browser
- Dev: Browser automation skills.
Integration
- NotebookLM: Communicate directly with Google NotebookLM notebooks.
- Figma: Figma official skills and MCP server.
- Notion: Notion official skills, commands and MCP server.
- Obsidian:
Create and edit Obsidian Bases (
.base) with Obsidian Flavored Markdown. - Cloudflare.
Math
- Scientific: Comprehensive collection of ready-to-use scientific skills.
Guardrails
- SafetyNet: Catching destructive git and filesystem commands before they execute.
Assistant
- Life: Personal coach that remembers, notices patterns, and holds accountable.
- Health: Intelligent healthcare assistant.
Collections
- Skills: Anthropic repository for agent skills.
- Awesome: Curated list of Claude Code skills.
- Marketplace: Agent skills marketplace.
- Plugins: Anthropic-managed directory of high quality Claude Code plugins.
- Registry: Lightweight registry to discover and manage Claude plugins and agent skills.
- Build: Single hub to Claude Skills, Agents, Commands, Hooks, and Plugins.
References
- Agent skills best practices.
- Claude skills cookbook.
- OpenCode complete guide.