Skills and Commands
-
Skills: ~/.claude/skills - broader workflow definitions -
Commands: ~/.claude/commands - quick executable prompts
# Example skill structure
~/.claude/skills/
pmx-guidelines.md # Project-specific patterns
coding-standards.md # Language best practices
tdd-workflow/ # Multi-file skill with README.md
security-review/ # Checklist-based skill
Hooks
hook types:
- PreToolUse - Before a tool executes (validation, reminders)
- PostToolUse - After a tool finishes (formatting, feedback loops)
- UserPromptSubmit - When you send a message
- Stop - When Claude finishes responding
- PreCompact - Before context compaction
- Notification - Permission requests
使用 hookify 插件輔助編寫 hooks, 通過 /hookify觸發(fā)
Subagents
需要為每個(gè)子代理配置 tools, MCPs, permissions
# Example subagent structure
~/.claude/agents/
planner.md # Feature implementation planning
architect.md # System design decisions
tdd-guide.md # Test-driven development
code-reviewer.md # Quality/security review
security-reviewer.md # Vulnerability analysis
build-error-resolver.md
e2e-runner.md
refactor-cleaner.md
Rules and Memory
兩個(gè)實(shí)現(xiàn)途徑
- 單文件
CLAUDE.md - 子目錄
~/.claude/rules/
security.md # No hardcoded secrets, validate inputs
coding-style.md # Immutability, file organization
testing.md # TDD workflow, 80% coverage
git-workflow.md # Commit format, PR process
agents.md # When to delegate to subagents
performance.md # Model selection, context management
MCPs ( Model Context Protocol)
Rule of thumb: 關(guān)掉不用的 mcp, 可有效減少token, 盡量保持在 10個(gè)以下
Plugins
plugin 是 skill, mcp, hook 的組合,只是方便批量安裝
比如:
# Add a marketplace
claude plugin marketplace add https://github.com/mixedbread-ai/mgrep
# Open Claude, run /plugins, find new marketplace, install from there
- LSP 插件,方便代碼定位
# Enabled plugins example
typescript-lsp@claude-plugins-official # TypeScript intelligence
pyright-lsp@claude-plugins-official # Python type checking
hookify@claude-plugins-official # Create hooks conversationally
mgrep@Mixedbread-Grep # Better search than ripgrep
Tips and Tricks
熱鍵:
- Ctrl+U - Delete entire line (faster than backspace spam) // C-A, C-K 等價(jià)
- ! - Quick bash command prefix // 在 code 中執(zhí)行本地 shell ,這個(gè)比較有用
- @ - Search for files
- / - Initiate slash commands
- Shift+Enter - Multi-line input
- Tab - Toggle thinking display
- Esc Esc - Interrupt Claude / restore code
/fork貌似查看運(yùn)行中工作流的消息?-
Git Worktreesgit worktree add ../feature-branch feature-branch # Now run separate Claude instances in each worktree
-
tmux方便觀察日志tmux new -s dev # Claude runs commands here, you can detach and reattach tmux attach -t dev
-
mgrep支持本地和網(wǎng)絡(luò)的查詢插件,通過/mgrep調(diào)用。mgrep "function handleSubmit" # Local search mgrep --web "Next.js 15 app router changes" # Web search
-
有用的命令行
- /rewind - Go back to a previous state
- /statusline - Customize with branch, context %, todos
- /checkpoints - File-level undo points
- /compact - Manually trigger context compaction
My Setup (作者的配置)
Plugins
ralph-wiggum@claude-code-plugins # Loop automation
frontend-design@claude-code-plugins # UI/UX patterns
commit-commands@claude-code-plugins # Git workflow
security-guidance@claude-code-plugins # Security checks
pr-review-toolkit@claude-code-plugins # PR automation
typescript-lsp@claude-plugins-official # TS intelligence
hookify@claude-plugins-official # Hook creation
code-simplifier@claude-plugins-official
feature-dev@claude-code-plugins
explanatory-output-style@claude-code-plugins
code-review@claude-code-plugins
context7@claude-plugins-official # Live documentation
pyright-lsp@claude-plugins-official # Python types
mgrep@Mixedbread-Grep # Better search
MCP Servers
{
"github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"] },
"firecrawl": { "command": "npx", "args": ["-y", "firecrawl-mcp"] },
"supabase": {
"command": "npx",
"args": ["-y", "@supabase/mcp-server-supabase@latest", "--project-ref=YOUR_REF"]
},
"memory": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-memory"] },
"sequential-thinking": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
},
"vercel": { "type": "http", "url": "https://mcp.vercel.com" },
"railway": { "command": "npx", "args": ["-y", "@railway/mcp-server"] },
"cloudflare-docs": { "type": "http", "url": "https://docs.mcp.cloudflare.com/mcp" },
"cloudflare-workers-bindings": {
"type": "http",
"url": "https://bindings.mcp.cloudflare.com/mcp"
},
"cloudflare-workers-builds": { "type": "http", "url": "https://builds.mcp.cloudflare.com/mcp" },
"cloudflare-observability": {
"type": "http",
"url": "https://observability.mcp.cloudflare.com/mcp"
},
"clickhouse": { "type": "http", "url": "https://mcp.clickhouse.cloud/mcp" },
"AbletonMCP": { "command": "uvx", "args": ["ableton-mcp"] },
"magic": { "command": "npx", "args": ["-y", "@magicuidesign/mcp@latest"] }
}
Disabled per project (context window management)
# In ~/.claude.json under projects.[path].disabledMcpServers
disabledMcpServers: [
"playwright",
"cloudflare-workers-builds",
"cloudflare-workers-bindings",
"cloudflare-observability",
"cloudflare-docs",
"clickhouse",
"AbletonMCP",
"context7",
"magic"
]
Key Hooks
{
"PreToolUse": [
// tmux reminder for long-running commands
{ "matcher": "npm|pnpm|yarn|cargo|pytest", "hooks": ["tmux reminder"] },
// Block unnecessary .md file creation
{ "matcher": "Write && .md file", "hooks": ["block unless README/CLAUDE"] },
// Review before git push
{ "matcher": "git push", "hooks": ["open editor for review"] }
],
"PostToolUse": [
// Auto-format JS/TS with Prettier
{ "matcher": "Edit && .ts/.tsx/.js/.jsx", "hooks": ["prettier --write"] },
// TypeScript check after edits
{ "matcher": "Edit && .ts/.tsx", "hooks": ["tsc --noEmit"] },
// Warn about console.log
{ "matcher": "Edit", "hooks": ["grep console.log warning"] }
],
"Stop": [
// Audit for console.logs before session ends
{ "matcher": "*", "hooks": ["check modified files for console.log"] }
]
}
Custom Status Line
Shows user, directory, git branch with dirty indicator, context remaining %, model, time, and todo count:
Rules Structure
~/.claude/rules/
security.md # Mandatory security checks
coding-style.md # Immutability, file size limits
testing.md # TDD, 80% coverage
git-workflow.md # Conventional commits
agents.md # Subagent delegation rules
patterns.md # API response formats
performance.md # Model selection (Haiku vs Sonnet vs Opus)
hooks.md # Hook documentation
Subagents
~/.claude/agents/
planner.md # Break down features
architect.md # System design
tdd-guide.md # Write tests first
code-reviewer.md # Quality review
security-reviewer.md # Vulnerability scan
build-error-resolver.md
e2e-runner.md # Playwright tests
refactor-cleaner.md # Dead code removal
doc-updater.md # Keep docs synced
Key Takeaways
- Don't overcomplicate - treat configuration like fine-tuning, not architecture
- Context window is precious - disable unused MCPs and plugins
- Parallel execution - fork conversations, use git worktrees
- Automate the repetitive - hooks for formatting, linting, reminders
- Scope your subagents - limited tools = focused execution