Skip to content

Commit d03c404

Browse files
committed
feat: reorganize knowledge base into structured knol directory
- Move analysis documents to knol/analysis/ - Move requirements to knol/requirements/ - Move workflows to knol/workflows/ - Add new reference documents in knol/references/ - Add acceptance criteria stash - Add GitHub branch protection setup analysis - Update CLAUDE.md with project guidance
1 parent d28d9f0 commit d03c404

21 files changed

Lines changed: 2288 additions & 130 deletions

CLAUDE.md

Lines changed: 12 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
44

5-
This project's root directory is file:~/Projects/github.com/typicode/husky-to-samoid/.
5+
This project's root directory is <file:~/Projects/github.com/typicode/husky-to-samoid/>.
66

77
## Project Overview
88

@@ -80,14 +80,14 @@ Uses dependency injection pattern for complete test isolation and exceptional qu
8080

8181
**Test Isolation Pattern:**
8282
```rust
83-
#[test]
83+
#[test]
8484
fn test_example() {
8585
// Completely isolated - no shared state or system dependencies
8686
let env = MockEnvironment::new().with_var("HUSKY", "0");
8787
let runner = MockCommandRunner::new()
8888
.with_response("git", &["config", "core.hooksPath", ".samoid/_"], Ok(output));
8989
let fs = MockFileSystem::new().with_directory(".git");
90-
90+
9191
let result = install_hooks(&env, &runner, &fs, None);
9292
assert!(result.is_ok());
9393
}
@@ -101,7 +101,7 @@ fn test_example() {
101101

102102
**Testing Strategy Levels:**
103103
1. **Real System Integration**: Tests with `SystemFileSystem` validate production implementations
104-
2. **Mock Error Scenarios**: Comprehensive edge case and error condition testing
104+
2. **Mock Error Scenarios**: Comprehensive edge case and error condition testing
105105
3. **Main Logic Testing**: All execution paths without binary execution
106106
4. **Parallel Execution**: Thread-safe mocks enable reliable concurrent testing
107107

@@ -110,7 +110,7 @@ fn test_example() {
110110
[default]
111111
run-types = ["Tests"]
112112

113-
[report]
113+
[report]
114114
output-dir = "target/tarpaulin/coverage"
115115
out = ["Html", "Json"]
116116
```
@@ -121,129 +121,11 @@ out = ["Html", "Json"]
121121
- **Iterative Improvement**: 4-step approach: baseline → DI implementation → legacy removal → comprehensive testing
122122
- **Meaningful Coverage**: Focus on behavioral validation rather than just coverage numbers
123123

124-
## Error Prevention Guidelines
125-
126-
### GitHub API Operations
127-
**Always validate before GitHub operations to prevent API failures:**
128-
129-
```bash
130-
# Validate labels before adding them
131-
gh label list --repo OWNER/REPO --json name | jq -r '.[].name' | grep -q "^TARGET_LABEL$"
132-
if [ $? -eq 0 ]; then
133-
gh issue edit ISSUE --add-label "TARGET_LABEL"
134-
else
135-
# Fallback: use comments for status tracking
136-
gh issue comment ISSUE --body "Status: TARGET_STATUS"
137-
fi
138-
```
139-
140-
**Required validations:**
141-
- Check label existence before `gh issue edit --add-label`
142-
- Verify repository permissions before label creation
143-
- Always provide comment fallbacks for status tracking
144-
145-
### Directory Context Management
146-
**Always verify working directory before language-specific commands:**
147-
148-
```bash
149-
# For Rust commands - verify Cargo.toml exists
150-
if [[ ! -f "Cargo.toml" ]]; then
151-
echo "Error: Not in Rust project directory"
152-
# Search for Rust project: find . -name "Cargo.toml" -type f
153-
exit 1
154-
fi
155-
cargo test
156-
157-
# Alternative: Use explicit paths for monorepo
158-
cargo test --manifest-path ~/Projects/github.com/typicode/husky-to-samoid/samoid/Cargo.toml
159-
```
160-
161-
**Directory validation patterns:**
162-
- Check for `Cargo.toml` before `cargo` commands
163-
- Check for `package.json` before `npm`/`yarn` commands
164-
- Use `pwd` to verify current location
165-
- Prefer explicit paths (`--manifest-path`) over `cd` when possible
166-
167-
### Tool Execution Safety
168-
**Validate environment before executing commands:**
169-
170-
```bash
171-
# Template for safe command execution
172-
validateAndExecute() {
173-
local tool="$1"
174-
local cmd="$2"
175-
local required_file="$3"
176-
177-
if [[ ! -f "$required_file" ]]; then
178-
echo "❌ Missing $required_file for $tool command"
179-
return 1
180-
fi
181-
182-
if ! command -v "$tool" >/dev/null 2>&1; then
183-
echo "$tool not found in PATH"
184-
return 1
185-
fi
186-
187-
eval "$tool $cmd"
188-
}
189-
190-
# Usage examples:
191-
# validateAndExecute cargo "test" "Cargo.toml"
192-
# validateAndExecute npm "test" "package.json"
193-
```
194-
195-
196-
## Acceptance Criteria Format Standards
197-
198-
### Required Format for GitHub Issues
199-
200-
Use this format for all acceptance criteria in GitHub issues:
201-
202-
**For 9+ acceptance criteria (use phases):**
203-
```
204-
#### Phase <n>: <Phase Name> (<n> story points)
205-
- [ ] **AC<issueNumber>.<n>** Description of acceptance criterion
206-
- [ ] **AC<issueNumber>.<n>** Description of acceptance criterion
207-
```
208-
209-
**For <9 acceptance criteria (no phases):**
210-
```
211-
- [ ] **AC<issueNumber>.<n>** Description of acceptance criterion
212-
- [ ] **AC<issueNumber>.<n>** Description of acceptance criterion
213-
```
214-
215-
**Examples:**
216-
217-
*Multi-phase format:*
218-
```
219-
#### Phase 1: Core Infrastructure (8 story points)
220-
- [ ] **AC5.1** Implement `IsolatedEnvironment` trait and `MockIsolatedEnvironment`
221-
- [ ] **AC5.2** Implement `IsolatedFileSystem` trait with temp directory management
222-
- [ ] **AC5.3** Create `TestContext` with automatic cleanup
223-
224-
#### Phase 2: Advanced Features (5 story points)
225-
- [ ] **AC5.4** Implement `StatefulMock` system for complex behavior simulation
226-
- [ ] **AC5.5** Add `TimeProvider` abstraction for time-dependent testing
227-
```
228-
229-
*Simple format:*
230-
```
231-
- [ ] **AC5.1** Implement `IsolatedEnvironment` trait and `MockIsolatedEnvironment`
232-
- [ ] **AC5.2** Implement `IsolatedFileSystem` trait with temp directory management
233-
- [ ] **AC5.3** Create `TestContext` with automatic cleanup
234-
```
235-
236-
### Guidelines:
237-
- Always prefix with `AC<issueNumber>.` for traceability
238-
- Use descriptive but concise criterion descriptions
239-
- Group into logical phases for complex features (9+ criteria)
240-
- Assign story points to phases, not individual criteria
241-
- Ensure criteria are testable and unambiguous
242-
243-
## Session Reminders
124+
## Directory Context Management
125+
**ALWAYS:** verify working directory before Samoid/Husky-specific commands**
126+
**REMEMBER:** the project's root directory is <file:~/Projects/github.com/typicode/husky-to-samoid/>
127+
**REMEMBER:** you can always use `pwd` to verify current location
128+
**REMEMBER:** some commands accept absolute paths via flags, and when possible, that can help you avoid changing directory with `cd`
244129

245-
### TODO: Work on permission issues
246-
The Samoid hook runner is encountering permission issues during commit operations:
247-
- `.samoid/_/prepare-commit-msg: 3: exec: .git/COMMIT_EDITMSG: Permission denied`
248-
- This affects the git commit workflow when hooks are enabled
249-
- Need to investigate and fix the permission handling in the hook runner implementation
130+
- For Samoid, check for `Cargo.toml` before `cargo` commands
131+
- For Husky, check for `package.json` before reading files.
File renamed without changes.

analysis/003-dependency-injection-test-isolation.md renamed to knol/analysis/003-dependency-injection-test-isolation.md

File renamed without changes.

analysis/004-github-branch-protection-setup-errors.md renamed to knol/analysis/004-github-branch-protection-setup-errors.md

File renamed without changes.

0 commit comments

Comments
 (0)