Unify CLAUDE.md in English; update git/address preferences

Why: keep a single language register for the global guide, and reflect
Charles's updated defaults (push when possible, address as Charles).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Knowit
2026-04-20 21:23:12 +08:00
parent 6406ef36a5
commit ce33e4351a

View File

@@ -4,60 +4,60 @@ Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-s
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment. **Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
## 0. Personal Preferences
- **Address the user as**: Charles
- **Reply language**: Chinese for prose; keep code, commands, and technical terms in English
- **Git push policy**: push by default when there are commits. Only skip if the user says not to, or the repo lacks a remote / credentials
- **Version-control hygiene**: commit messages must explain *why*, not just *what*. Confirm before risky ops (`push --force`, `reset --hard`, `rm -rf`, branch deletion)
- **Default git remote**: `git.deepknow.site` (credentials stored in memory)
- **Package managers**: `pnpm` (Node), `uv` (Python), `cargo` (Rust)
- **Indentation**: 4 spaces by default; follow project convention if different
## 1. Think Before Coding ## 1. Think Before Coding
**Don't assume. Don't hide confusion. Surface tradeoffs.** **Don't assume. Don't hide confusion. Surface tradeoffs.**
Before implementing: Before implementing:
- State your assumptions explicitly. If uncertain, ask. - State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them - don't pick silently. - If multiple interpretations exist, present them don't pick silently.
- If a simpler approach exists, say so. Push back when warranted. - If a simpler approach exists, say so. Push back when warranted.
- If something is unclear, stop. Name what's confusing. Ask. - If something is unclear, stop. Name what's confusing. Ask.
## 2. Simplicity First ## 2. Simplicity First
**Minimum code that solves the problem. Nothing speculative.** **Minimum code. Explain before adding complexity.**
- No features beyond what was asked. Hard rules (not self-reflection):
- No abstractions for single-use code. - Before writing a function longer than 50 lines, stop and explain why.
- No "flexibility" or "configurability" that wasn't requested. - Before introducing a new file or abstraction, justify why inline / one-off code isn't enough.
- No error handling for impossible scenarios. - Before implementing, describe the shortest path in one sentence.
- If you write 200 lines and it could be 50, rewrite it.
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
## 3. Surgical Changes ## 3. Surgical Changes
**Touch only what you must. Clean up only your own mess.** **Touch only what you must. Every changed line should trace to the user's request.**
When editing existing code:
- Don't "improve" adjacent code, comments, or formatting. - Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently. - Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it - don't delete it. - If you notice unrelated dead code or issues, **list them and wait for confirmation** — never "clean up" as a side effect.
When your changes create orphans: When your changes create orphans:
- Remove imports / variables / functions that YOUR changes made unused. - Remove imports / variables / functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked. - Don't remove pre-existing dead code unless asked.
The test: Every changed line should trace directly to the user's request.
## 4. Goal-Driven Execution ## 4. Goal-Driven Execution
**Define success criteria. Loop until verified.** **Define success criteria before implementing.**
Transform tasks into verifiable goals:
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"
For multi-step tasks, state a brief plan: For multi-step tasks, state a brief plan:
``` ```
1. [Step] → verify: [check] 1. [Step] → verify: [check]
2. [Step] → verify: [check] 2. [Step] → verify: [check]
3. [Step] → verify: [check]
``` ```
- **Test framework present + bug fix / new feature**: write a failing test first, then make it pass.
- **Exploratory scripts / one-off data processing / untested projects**: success criterion is a concrete output or observable behavior, not tests.
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification. Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
--- ---