claude-code-usage
1
总安装量
1
周安装量
#76700
全站排名
安装命令
npx skills add https://github.com/neversight/skills_feed --skill claude-code-usage
Agent 安装分布
amp
1
opencode
1
cursor
1
kimi-cli
1
codex
1
github-copilot
1
Skill 文档
Claude Code Best Practices
Language Rule
- Always respond in the same language the user is using. If the user asks in Chinese, respond in Chinese. If in English, respond in English.
Context Management Rules
| Rule | Why |
|---|---|
| One window = one task | Mixing tasks pollutes context and degrades output quality |
Use /clear over /compact |
Clean start is more reliable than compressed context |
/clear after complex tasks |
Prevents old context from interfering with new work |
| Copy key info to new windows | Don’t rely on context persistence â paste critical details |
Task Execution Strategy
| Task Type | Recommended Approach |
|---|---|
| Small bug fix (few lines) | Describe directly, let Claude modify in-place |
| Large feature / refactor | /plan â review approach â /clear â paste plan â execute step by step |
| Multi-file changes | Must use /plan workflow â never modify multiple files without a plan |
| Code analysis / learning | Ask Claude to analyze directly â no plan needed |
| Debugging | Provide error message + file path + relevant code â ask for root cause |
Prompt Techniques
Do This
- Give specific paths: “Modify the
_transferfunction insrc/MyToken.sol“ - Give examples: “Input: 100 tokens, Expected: 95 tokens after 5% fee”
- Set boundaries: “Only modify this function, don’t touch other code”
- Reference tests: “The fix should make
test_transfer_feeDeductionpass”
Avoid This
- Vague references: “Modify that transfer function” â which one? Where?
- Open-ended requests without constraints: “Make it better”
- Multiple unrelated tasks in one message
Meta-Prompting â When Things Go Wrong
When Claude’s response misses the mark, don’t just rephrase and retry. Use Meta-Prompting (reverse prompting) to let Claude diagnose the gap, then re-ask with complete context.
Four Prompt Types
| Type | When to Use | Template |
|---|---|---|
| Diagnose | Answer was wrong or incomplete | “æåæçæé®ä¸ç¼ºå°äºåªäºå ³é®ä¿¡æ¯ï¼å¯¼è´ä½ 没è½ä¸æ¬¡æ§ç»åºæ£ç¡®çæ¡ï¼è¯·éæ¡ååºã” |
| Rewrite | You don’t know how to improve the question | “请帮æéååæçé®é¢ï¼è¡¥å ¨ä½ 认为缺失çä¸ä¸æï¼ä½¿ä½ è½ä¸æ¬¡æ§ç»åºæ£ç¡®çæ¡ã” |
| Template | Prevent same mistake next time | “对äºè¿ç±»é®é¢ï¼æåºè¯¥æä¾åªäºä¿¡æ¯ä½ æè½ä¸æ¬¡æ§è§£å³ï¼è¯·ç»æä¸ä¸ªæé®æ¨¡æ¿ã” |
| Pre-check | Before Claude starts working | “å¨ä½ å¼å§å代ç ä¹åï¼ååºä½ è¿éè¦ææä¾çææä¿¡æ¯ã” |
Recommended Flow
Step 1: Ask your question
â (answer is wrong or incomplete)
Step 2: Use [Diagnose] â "æçé®é¢ä¸ç¼ºå°äºä»ä¹ï¼"
â (Claude lists missing info)
Step 3: Use [Rewrite] â "帮æéåè¿ä¸ªé®é¢"
â (Claude outputs a complete, self-contained prompt)
Step 4: Copy the rewritten prompt, `/clear`, paste and send
â (clean context + complete prompt = correct answer)
Practical Example
# Round 1 â incomplete question
User: "帮æåä¸ä¸ª staking å约"
Claude: (generates a basic staking contract, but missing reward logic)
# Round 2 â diagnose
User: "æåæçæé®ä¸ç¼ºå°äºåªäºä¿¡æ¯ï¼"
Claude: "ä½ æ²¡æè¯´æï¼
1. è´¨æ¼ä»£å¸åå¥å±ä»£å¸æ¯å¦ç¸å
2. å¥å±ååæºå¶ï¼ææ¶é´/æåºå/åºå®APRï¼
3. æ¯å¦éè¦é仿
4. æ¯å¦éè¦ç´§æ¥æååè½
5. 管çåæéèå´"
# Round 3 â rewrite
User: "帮æéåè¿ä¸ªé®é¢"
Claude: "请帮æåä¸ä¸ª Staking å约ï¼è¦æ±å¦ä¸ï¼
- è´¨æ¼ä»£å¸ï¼ERC20 TOKEN_Aï¼å¥å±ä»£å¸ï¼ERC20 TOKEN_B
- å¥å±æºå¶ï¼æè´¨æ¼æ¶é¿çº¿æ§éæ¾ï¼å¹´å 12%
- é仿ï¼7 天æçéä»
- ç´§æ¥æåï¼æ¯æï¼ä½æ£é¤ 10% ç½é
- 管çåï¼å¯æ´æ°å¥å±çï¼ä¸å¯è§¦ç¢°ç¨æ·è´¨æ¼èµé
- å®å
¨ï¼ä½¿ç¨ ReentrancyGuard + SafeERC20
请åºäº OpenZeppelin 5.xï¼Solidity ^0.8.20ï¼Foundry 项ç®ç»æã"
# Round 4 â /clear, paste rewritten prompt, get correct result
Key Principle
Don’t guess what you missed â let Claude tell you. One round of meta-prompting saves multiple rounds of trial and error.
Git Operation Rules
- Always run
git diffbefore committing to review changes - Only commit â do not push unless explicitly requested
- Never push directly to main/master branch
- Stage specific files â never use
git add .in Solidity projects (risk of committing.env)
Foundry-Specific Workflow
| Action | Command |
|---|---|
| Before committing | forge fmt && forge test |
| After modifying contracts | forge build to check compilation |
| Before PR | forge test --gas-report to check gas impact |
| Debugging failed test | forge test --match-test <name> -vvvv for full trace |
Quick Command Reference
| Command | Purpose |
|---|---|
/clear |
Clear context, start fresh |
/plan |
Enter planning mode â analyze before modifying |
/help |
View all available commands |
/compact |
Compress context (prefer /clear instead) |
Project-level Configuration
Create .claude/instructions.md in the project root with project-specific rules. Claude automatically reads it at the start of every conversation â no manual loading needed.