# 檔案位置
~/your-project/CLAUDE.md
# Claude 行為
claude
├─ 讀取 CLAUDE.md
├─ 記住所有規則
├─ 每次你輸入 prompt 時遵守
└─ 不再需要你重複告訴它
類比:
傳統方式 = 每次進公司都告訴員工「要穿正式服裝」
CLAUDE.md 方式 = 第一天讀 dress code,以後自動遵守
一人公司應該在 CLAUDE.md 裡寫什麼
第一層:基本信息(不改的東西)
# Project: Taiwan Invoice System
**Stack**: React 18 + Node.js 18 + PostgreSQL
**Language**: TypeScript (strict mode)
**Main concern**: Taiwan tax law compliance
---
## Architecture Decision Log
### Decision 1: Use Strategy Pattern for tax calculation
**Why**: Taiwan tax law changes frequently (new government = new rates)
**Impact**: New tax type can be added in 30 min, not 8 hours
**Done**: ✅
### Decision 2: Keep invoice data immutable once submitted
**Why**: Taiwan tax audit requires unmodifiable records
**Impact**: No delete/edit after submit, only void new ones
**Done**: ✅
好處:
6 個月後你自己看,能快速想起設計邏輯
新人(或外包)接手,有據可查
Claude 理解你的業務優先級
第二層:代碼標準(重複最多的東西)
## Code Standards
### File Structure
```
src/
├── components/ # React components
├── pages/ # Page-level components
├── services/ # API calls & business logic
├── utils/ # Helpers
├── hooks/ # Custom React hooks
├── styles/ # CSS modules
└── __tests__/ # Test files (mirror structure)
```
### Naming Conventions
- Components: PascalCase (e.g., InvoiceForm.tsx)
- Utilities: camelCase (e.g., calculateTax.ts)
- Constants: UPPER_SNAKE_CASE (e.g., MAX_INVOICE_AMOUNT)
- Database tables: snake_case (e.g., c_invoice)
### Code Quality Rules
**MUST HAVE**:
- [ ] TypeScript (no `any` type)
- [ ] Unit tests for all logic (TDD)
- [ ] JSDoc for public functions
- [ ] Error handling (no silent failures)
**NEVER**:
- ❌ Hardcode config values (use .env)
- ❌ Leave console.log() in production code
- ❌ Commit commented-out code
- ❌ Use var (only let/const)
為什麼重要:
Claude 有了標準,自動遵守
省去每個 prompt 都要說「按 TypeScript best practices」
代碼風格一致,review 更快
第三層:業務邏輯(最容易被遺忘的)
## Taiwan-Specific Rules
### Tax Calculation
- Standard VAT: 5% (applies to most goods)
- Zero-rated: 0% (exports, specific items)
- Tax-exempt: 0% (non-profit, some services)
- Input tax can be deducted if invoice dated in same month
### Invoice Rules
- Invoice number format: GUN (Government Uniform Number)
- Sequence must be continuous
- Cannot be modified after submission
- Must include buyer's company ID + name
- QR code is mandatory for official submission
### Compliance
- Must report to MOPS (Ministry system) by 15th of next month
- Annual audit by tax bureau
- Keep records for 10 years
為什麼重要:
Claude 有了背景,不會犯「常見的 bug」
減少審查時需要找的問題
新人學習曲線 ÷ 2
第四層:技術決策(省掉最多討論時間)
## When You Ask Claude to Build Something
### Before Implementation (Planning Phase)
1. Claude enters Plan Mode automatically
2. Claude reads this CLAUDE.md + design docs
3. Claude proposes approach
4. **YOU APPROVE** (or suggest changes)
5. Claude implements
### Testing Strategy
- Unit tests: Must cover edge cases
- Integration tests: For API + database interaction
- Manual testing: Only for UI/UX
- Coverage target: > 85%
### Code Review Checklist
- [ ] Logic is correct (test passes)
- [ ] Taiwan business rules followed
- [ ] No security holes
- [ ] Performance acceptable
- [ ] Error messages are clear (in Chinese)
- [ ] Documentation updated
為什麼重要:
Claude 知道你的評審標準
自動寫出符合預期的代碼
不用反覆改
一人公司版本的 CLAUDE.md 精簡版
如果你覺得上面太複雜,這是最小版本(30 分鐘可寫完):
# Taiwan Invoice System
## Stack & Language
- TypeScript + React 18 + Node.js
- Database: PostgreSQL
## Code Rules
- File structure: components/ pages/ services/ __tests__/
- Names: Components = PascalCase, functions = camelCase, constants = UPPER_CASE
- MUST: TypeScript strict, unit tests, JSDoc, error handling
- NEVER: console.log, hardcoded config, var, no tests
## Business Rules
- Tax rates: 5% standard, 0% zero-rated, 0% exempt
- Invoice format: GUN, continuous sequence, immutable after submit
- Compliance: Report to MOPS by 15th, keep records 10 years
## When You Ask Me to Build
1. I'll enter Plan Mode
2. Read design doc + this file
3. Propose approach (you approve)
4. Implement with tests
5. You review
## Important Decisions
1. Tax calculation uses Strategy Pattern (easy to add new rates)
2. Invoices immutable after submit (Taiwan law requirement)
---
Done! Keep this updated as rules change.
寫這個花了多少時間? 30-45 分鐘。
省了多少時間? 每週 3-5 小時(因為不用重複解釋)。
真實案例:有沒有 CLAUDE.md 的差別
沒有 CLAUDE.md 的一人公司
Day 1, Prompt:
"Build invoice form with validation.
Use React, TypeScript, follow best practices."
Claude builds... but:
- Uses var instead of const ❌
- Only 60% test coverage ❌
- API call has no error handling ❌
- Component name is lowercase ❌
You: "Oh no, 改了改了改了"
時間消耗:8 小時 (1 小時寫 + 7 小時改)
有 CLAUDE.md 的一人公司
Day 1, CLAUDE.md 寫好,然後 Prompt:
"Build invoice form with validation"
Claude builds:
- Automatically uses let/const ✅
- Automatically writes unit tests ✅
- Automatically adds error handling ✅
- Automatically uses PascalCase ✅
You: "一次到位!"
時間消耗:2.5 小時 (30 分鐘規劃 + 2 小時實施)