Skip to content

Commit 25f8a33

Browse files
authored
feat: improve code implementaion (#112)
1 parent db21359 commit 25f8a33

File tree

164 files changed

+15593
-3754
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+15593
-3754
lines changed

.claude/CLAUDE.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Zerv is a dynamic versioning CLI tool written in Rust that generates versions for any commit from git and other version control systems. It supports multiple version formats (SemVer, PEP440, CalVer) and is designed for CI/CD builds.
8+
9+
---
10+
11+
## 🎯 Critical Rules (Quick Reference)
12+
13+
**MANDATORY - These rules must ALWAYS be followed:**
14+
15+
1.**Use constants** instead of bare strings (fields, formats, sources, schemas) → Use `crate::utils::constants::*`
16+
- **For environment variables**: Use `crate::config::EnvVars::*` (e.g., `EnvVars::PAGER`, `EnvVars::RUST_LOG`)
17+
2.**Use `ZervError`** for custom errors and `io::Error::other()` for IO errors
18+
3.**Use `get_git_impl()`** for environment-aware Git operations
19+
4.**Use `should_run_docker_tests()`** for Docker-dependent tests
20+
5.**Never reuse Git implementations** across different directories
21+
6.**Include detailed error context** in all error messages
22+
7.**NO useless comments** - only comment when code cannot explain itself
23+
8.**Check existing utilities** in `src/test_utils/` before creating new ones
24+
9.**Place `use` statements at top of file/module** - never inside functions
25+
10.**Use `mod` blocks for test organization** - not comment dividers
26+
27+
**NEVER do these:**
28+
29+
1. ❌ Use bare string literals for field/format/source names
30+
2. ❌ Use `unwrap()` or `expect()` in production code
31+
3. ❌ Add comments that just repeat function names or restate code
32+
4. ❌ Create Git fixtures without proper isolation
33+
5. ❌ Skip Docker test gating for Docker-dependent tests
34+
6. ❌ Write generic error messages without context
35+
7. ❌ Duplicate code instead of using existing utilities
36+
8. ❌ Place `use` statements inside functions (except rare naming conflict cases)
37+
9. ❌ Use comment dividers for test grouping (use `mod` blocks instead)
38+
39+
**📋 Run `/audit` to check and fix violations automatically**
40+
41+
---
42+
43+
## 📚 Planning Workflow
44+
45+
### Check Existing Plans First
46+
47+
**BEFORE performing ANY coding task, check `.claude/plan/` for existing plans and context.**
48+
49+
Plans in `.claude/plan/` are temporary working documents with short lifecycle:
50+
51+
- Created when planning new features/refactors
52+
- Used during implementation
53+
- Deleted or archived when task is complete
54+
55+
### Creating New Plans
56+
57+
**CRITICAL: When user asks you to "write a plan" or "create a plan", you MUST:**
58+
59+
1.**Check existing `.claude/plan/` files** to find the highest number
60+
2.**Create new plan** as `.claude/plan/XX-descriptive-name.md` (increment XX)
61+
3.**Do NOT start coding** until the plan is reviewed and approved
62+
4.**Use ExitPlanMode tool** to present the plan for approval
63+
64+
**Plan Document Structure:**
65+
66+
- **Status**: Planned/In Progress/Completed
67+
- **Priority**: High/Medium/Low
68+
- **Context**: Why this work is needed
69+
- **Goals**: What we want to achieve
70+
- **Implementation Plan**: Detailed steps
71+
- **Testing Strategy**: How to validate
72+
- **Success Criteria**: Definition of done
73+
- **Documentation Updates**: What docs need updating
74+
75+
**Note**: Plans can reference `.claude/ref/` docs, but `.claude/ref/` should NEVER reference specific plans (one-way dependency).
76+
77+
---
78+
79+
## 📖 Essential Commands & Workflows
80+
81+
@.claude/ref/workflows/commands.md
82+
@.claude/ref/workflows/coverage.md
83+
84+
---
85+
86+
## 🏗️ Architecture
87+
88+
### Pipeline Overview
89+
90+
```
91+
Input → VCS Detection → Version Parsing → Transformation → Format Output
92+
```
93+
94+
**For detailed architecture documentation:**
95+
96+
@.claude/ref/architecture/pipeline.md
97+
@.claude/ref/architecture/modules.md
98+
@.claude/ref/architecture/cli.md
99+
100+
---
101+
102+
## 🚨 Code Standards
103+
104+
### Quick Reference
105+
106+
- **Comments**: Only when code can't explain itself
107+
- **Imports**: Always at top of file/module
108+
- **Test organization**: Use `mod` blocks, not comment dividers
109+
- **Line length**: Max 100 chars (rustfmt), use `format!()` for long strings
110+
111+
**For detailed standards:**
112+
113+
@.claude/ref/standards/code-style.md
114+
@.claude/ref/standards/error-handling.md
115+
@.claude/ref/standards/logging.md
116+
@.claude/ref/standards/constants.md
117+
118+
---
119+
120+
## 🧪 Testing Standards
121+
122+
### Quick Reference
123+
124+
- **Environment variables**: `ZERV_TEST_NATIVE_GIT`, `ZERV_TEST_DOCKER`
125+
- **Git operations**: Always use `get_git_impl()`
126+
- **Docker tests**: Always use `should_run_docker_tests()` gating
127+
- **Integration tests**: Prefer `TestCommand::run_with_stdin()` (90% of cases)
128+
129+
**For detailed testing patterns:**
130+
131+
@.claude/ref/testing/overview.md
132+
@.claude/ref/testing/unit-tests.md
133+
@.claude/ref/testing/integration-tests.md
134+
135+
---
136+
137+
## 🚀 CI/CD
138+
139+
@.claude/ref/workflows/cicd.md
140+
141+
---
142+
143+
## 🛠️ Using Claude Code Features
144+
145+
### When to Use What
146+
147+
**Slash Commands** (Simple, predefined workflows):
148+
149+
- `/audit` - Run code quality audit and fix violations
150+
- Use for: Detecting and fixing code quality violations efficiently
151+
152+
**Agents** (Complex, multi-step exploration):
153+
154+
- Codebase exploration: "How does version bumping work across the codebase?"
155+
- Large refactoring: "Migrate all tests to use environment-aware pattern"
156+
- Research tasks: "Find all API endpoints and document them"
157+
- Use for: Open-ended tasks requiring autonomous decision-making
158+
159+
**Direct Questions** (Fastest for simple tasks):
160+
161+
- "Review this function for bugs"
162+
- "Explain how this works"
163+
- "Fix the error in this code"
164+
- Use for: Quick reviews, explanations, single-file changes
165+
166+
**Rule of thumb**:
167+
168+
1. Try direct question first (fastest)
169+
2. Use slash command for standardized workflows
170+
3. Use agent only for complex multi-file exploration/refactoring

0 commit comments

Comments
 (0)