@paths.design/caws-cli 8.1.0 → 8.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/dist/commands/archive.d.ts +1 -1
- package/dist/commands/archive.d.ts.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +185 -39
- package/dist/commands/mode.d.ts +2 -1
- package/dist/commands/mode.d.ts.map +1 -1
- package/dist/commands/provenance.d.ts.map +1 -1
- package/dist/commands/quality-gates.js +1 -1
- package/dist/commands/specs.d.ts.map +1 -1
- package/dist/commands/worktree.d.ts +7 -0
- package/dist/commands/worktree.d.ts.map +1 -0
- package/dist/commands/worktree.js +136 -0
- package/dist/config/lite-scope.d.ts +33 -0
- package/dist/config/lite-scope.d.ts.map +1 -0
- package/dist/config/lite-scope.js +158 -0
- package/dist/config/modes.d.ts +90 -51
- package/dist/config/modes.d.ts.map +1 -1
- package/dist/config/modes.js +26 -0
- package/dist/error-handler.d.ts +3 -16
- package/dist/error-handler.d.ts.map +1 -1
- package/dist/generators/jest-config-generator.d.ts +32 -0
- package/dist/generators/jest-config-generator.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/scaffold/claude-hooks.d.ts +28 -0
- package/dist/scaffold/claude-hooks.d.ts.map +1 -0
- package/dist/scaffold/claude-hooks.js +28 -0
- package/dist/scaffold/index.d.ts +2 -0
- package/dist/scaffold/index.d.ts.map +1 -1
- package/dist/scaffold/index.js +90 -88
- package/dist/templates/.caws/schemas/scope.schema.json +52 -0
- package/dist/templates/.caws/schemas/working-spec.schema.json +1 -1
- package/dist/templates/.caws/schemas/worktrees.schema.json +36 -0
- package/dist/templates/.claude/hooks/block-dangerous.sh +33 -0
- package/dist/templates/.claude/hooks/lite-sprawl-check.sh +117 -0
- package/dist/templates/.claude/hooks/scope-guard.sh +93 -6
- package/dist/templates/.claude/hooks/simplification-guard.sh +92 -0
- package/dist/templates/.cursor/README.md +0 -3
- package/dist/templates/.github/copilot-instructions.md +82 -0
- package/dist/templates/.junie/guidelines.md +73 -0
- package/dist/templates/.vscode/launch.json +0 -27
- package/dist/templates/.windsurf/rules/caws-quality-standards.md +54 -0
- package/dist/templates/CLAUDE.md +101 -0
- package/dist/templates/agents.md +73 -1016
- package/dist/templates/docs/README.md +5 -5
- package/dist/test-analysis.d.ts +50 -1
- package/dist/test-analysis.d.ts.map +1 -1
- package/dist/utils/error-categories.d.ts +52 -0
- package/dist/utils/error-categories.d.ts.map +1 -0
- package/dist/utils/gitignore-updater.d.ts +1 -1
- package/dist/utils/gitignore-updater.d.ts.map +1 -1
- package/dist/utils/gitignore-updater.js +4 -0
- package/dist/utils/ide-detection.js +133 -0
- package/dist/utils/quality-gates-utils.d.ts +49 -0
- package/dist/utils/quality-gates-utils.d.ts.map +1 -0
- package/dist/utils/typescript-detector.d.ts +8 -5
- package/dist/utils/typescript-detector.d.ts.map +1 -1
- package/dist/validation/spec-validation.d.ts.map +1 -1
- package/dist/worktree/worktree-manager.d.ts +54 -0
- package/dist/worktree/worktree-manager.d.ts.map +1 -0
- package/dist/worktree/worktree-manager.js +378 -0
- package/package.json +5 -1
- package/templates/.caws/schemas/scope.schema.json +52 -0
- package/templates/.caws/schemas/working-spec.schema.json +1 -1
- package/templates/.caws/schemas/worktrees.schema.json +36 -0
- package/templates/.claude/hooks/block-dangerous.sh +33 -0
- package/templates/.claude/hooks/lite-sprawl-check.sh +117 -0
- package/templates/.claude/hooks/scope-guard.sh +93 -6
- package/templates/.claude/hooks/simplification-guard.sh +92 -0
- package/templates/.cursor/README.md +0 -3
- package/templates/.github/copilot-instructions.md +82 -0
- package/templates/.junie/guidelines.md +73 -0
- package/templates/.vscode/launch.json +0 -27
- package/templates/.windsurf/rules/caws-quality-standards.md +54 -0
- package/templates/AGENTS.md +104 -0
- package/templates/CLAUDE.md +101 -0
- package/templates/docs/README.md +5 -5
- package/templates/.github/copilot/instructions.md +0 -311
- package/templates/agents.md +0 -1047
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# CAWS Simplification Guard Hook
|
|
3
|
+
# Detects when files are being stubbed out (large deletions + stub content)
|
|
4
|
+
# @author @darianrosebrook
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
# Read JSON input from Claude Code
|
|
9
|
+
INPUT=$(cat)
|
|
10
|
+
|
|
11
|
+
# Extract tool info
|
|
12
|
+
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // ""')
|
|
13
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // ""')
|
|
14
|
+
|
|
15
|
+
# Only check Edit operations (modifications to existing files)
|
|
16
|
+
if [[ "$TOOL_NAME" != "Edit" ]]; then
|
|
17
|
+
exit 0
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
if [[ -z "$FILE_PATH" ]]; then
|
|
21
|
+
exit 0
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-.}"
|
|
25
|
+
|
|
26
|
+
# Get relative path (portable — macOS realpath lacks --relative-to)
|
|
27
|
+
if [[ "$FILE_PATH" == "$PROJECT_DIR"/* ]]; then
|
|
28
|
+
REL_PATH="${FILE_PATH#$PROJECT_DIR/}"
|
|
29
|
+
else
|
|
30
|
+
REL_PATH="$FILE_PATH"
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Only check code files
|
|
34
|
+
case "$REL_PATH" in
|
|
35
|
+
*.js|*.jsx|*.ts|*.tsx|*.mjs|*.cjs|*.py|*.rs|*.go|*.java|*.kt|*.swift|*.rb|*.php|*.c|*.cpp|*.h)
|
|
36
|
+
;;
|
|
37
|
+
*)
|
|
38
|
+
exit 0
|
|
39
|
+
;;
|
|
40
|
+
esac
|
|
41
|
+
|
|
42
|
+
# Check if the file exists in git (skip new files)
|
|
43
|
+
if ! git show "HEAD:$REL_PATH" >/dev/null 2>&1; then
|
|
44
|
+
exit 0
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
# Compare staged version with HEAD
|
|
48
|
+
if command -v node >/dev/null 2>&1; then
|
|
49
|
+
SIMP_CHECK=$(node -e "
|
|
50
|
+
const { execFileSync } = require('child_process');
|
|
51
|
+
try {
|
|
52
|
+
const headContent = execFileSync('git', ['show', 'HEAD:$REL_PATH'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
53
|
+
const currentContent = require('fs').readFileSync('$FILE_PATH', 'utf8');
|
|
54
|
+
|
|
55
|
+
const countLOC = (c) => c.split('\\n').filter(l => l.trim() && !l.trim().startsWith('//') && !l.trim().startsWith('#')).length;
|
|
56
|
+
const headLOC = countLOC(headContent);
|
|
57
|
+
const currentLOC = countLOC(currentContent);
|
|
58
|
+
|
|
59
|
+
if (headLOC < 10) { console.log('ok'); process.exit(0); }
|
|
60
|
+
|
|
61
|
+
const decrease = (headLOC - currentLOC) / headLOC;
|
|
62
|
+
|
|
63
|
+
// Check for stub patterns in new content
|
|
64
|
+
const stubPatterns = [/^\\s*pass\\s*$/m, /^\\s*\\.\\.\\.\\s*$/m, /raise\\s+NotImplementedError/,
|
|
65
|
+
/throw\\s+new\\s+Error.*not implemented/i, /\\/\\/\\s*TODO\\s*$/m, /#\\s*TODO\\s*$/m];
|
|
66
|
+
const hasStubs = stubPatterns.some(p => p.test(currentContent));
|
|
67
|
+
|
|
68
|
+
if (decrease >= 0.3 && hasStubs) {
|
|
69
|
+
console.log('simplified:' + Math.round(decrease * 100) + ':' + headLOC + ':' + currentLOC);
|
|
70
|
+
} else {
|
|
71
|
+
console.log('ok');
|
|
72
|
+
}
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.log('ok');
|
|
75
|
+
}
|
|
76
|
+
" 2>&1)
|
|
77
|
+
|
|
78
|
+
if [[ "$SIMP_CHECK" == simplified:* ]]; then
|
|
79
|
+
IFS=':' read -r _ PERCENT OLD_LOC NEW_LOC <<< "$SIMP_CHECK"
|
|
80
|
+
echo '{
|
|
81
|
+
"hookSpecificOutput": {
|
|
82
|
+
"hookEventName": "PreToolUse",
|
|
83
|
+
"permissionDecision": "ask",
|
|
84
|
+
"permissionDecisionReason": "WARNING: This edit would reduce '"$REL_PATH"' by '"$PERCENT"'% ('"$OLD_LOC"' → '"$NEW_LOC"' LOC) and introduces stub patterns (pass, TODO, NotImplementedError). This looks like a simplification — implementations should be modified, not replaced with stubs. Please confirm this is intentional."
|
|
85
|
+
}
|
|
86
|
+
}'
|
|
87
|
+
exit 0
|
|
88
|
+
fi
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
# Allow the edit
|
|
92
|
+
exit 0
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# CAWS Integration Instructions for GitHub Copilot
|
|
2
|
+
|
|
3
|
+
This project uses CAWS (Coding Agent Working Standard) for quality-assured AI-assisted development.
|
|
4
|
+
|
|
5
|
+
## CAWS Project Detection
|
|
6
|
+
|
|
7
|
+
Check if current project uses CAWS:
|
|
8
|
+
- Look for `.caws/working-spec.yaml` file
|
|
9
|
+
- Check for `caws` commands in package.json scripts
|
|
10
|
+
- Verify CAWS CLI availability: `caws --version`
|
|
11
|
+
|
|
12
|
+
## Working Specifications
|
|
13
|
+
|
|
14
|
+
Working specs define project requirements and constraints:
|
|
15
|
+
|
|
16
|
+
```yaml
|
|
17
|
+
id: PROJ-001
|
|
18
|
+
title: "Feature implementation"
|
|
19
|
+
risk_tier: 2 # 1=Critical, 2=Standard, 3=Low risk
|
|
20
|
+
mode: feature # feature|refactor|fix|chore
|
|
21
|
+
change_budget:
|
|
22
|
+
max_files: 25
|
|
23
|
+
max_loc: 1000
|
|
24
|
+
scope:
|
|
25
|
+
in: ["src/", "tests/"]
|
|
26
|
+
out: ["node_modules/", "dist/"]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Always validate working specs: `caws validate`
|
|
30
|
+
|
|
31
|
+
## Quality Workflow
|
|
32
|
+
|
|
33
|
+
1. **Before implementation**: `caws agent iterate --current-state "describe what you're about to do"`
|
|
34
|
+
2. **During implementation**: `caws agent evaluate --quiet`
|
|
35
|
+
3. **Before commit**: `caws validate && caws agent evaluate`
|
|
36
|
+
|
|
37
|
+
## Quality Gates by Risk Tier
|
|
38
|
+
|
|
39
|
+
| Gate | T1 (Critical) | T2 (Standard) | T3 (Low Risk) |
|
|
40
|
+
|------|---------------|----------------|----------------|
|
|
41
|
+
| Test coverage | 90%+ | 80%+ | 70%+ |
|
|
42
|
+
| Mutation score | 70%+ | 50%+ | 30%+ |
|
|
43
|
+
| Contracts | Required | Required | Optional |
|
|
44
|
+
| Manual review | Required | Optional | Optional |
|
|
45
|
+
|
|
46
|
+
## Key Rules
|
|
47
|
+
|
|
48
|
+
1. Stay within `scope.in` boundaries -- do not edit files in `scope.out`
|
|
49
|
+
2. Respect `change_budget.max_files` and `change_budget.max_loc` limits
|
|
50
|
+
3. No shadow files -- edit in place, never create `*-enhanced.*`, `*-new.*`, `*-v2.*` copies
|
|
51
|
+
4. Write tests before implementation when possible
|
|
52
|
+
5. Use conventional commits: `feat:`, `fix:`, `refactor:`, `docs:`, `chore:`
|
|
53
|
+
|
|
54
|
+
## Waivers
|
|
55
|
+
|
|
56
|
+
If you need to bypass a quality gate, create a waiver:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
caws waivers create --reason emergency_hotfix --gates coverage_threshold
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Valid reasons: `emergency_hotfix`, `legacy_integration`, `experimental_feature`, `performance_critical`, `infrastructure_limitation`
|
|
63
|
+
|
|
64
|
+
## Common Patterns
|
|
65
|
+
|
|
66
|
+
### Feature Development
|
|
67
|
+
1. Validate working spec: `caws validate`
|
|
68
|
+
2. Get implementation guidance: `caws agent iterate`
|
|
69
|
+
3. Implement with quality checks: `caws agent evaluate --quiet`
|
|
70
|
+
4. Run full validation: `caws validate && npm test`
|
|
71
|
+
|
|
72
|
+
### Bug Fixes
|
|
73
|
+
1. Assess risk tier and impact
|
|
74
|
+
2. Write failing test that reproduces the bug
|
|
75
|
+
3. Implement minimal fix
|
|
76
|
+
4. Run quality validation: `caws validate`
|
|
77
|
+
|
|
78
|
+
## Troubleshooting
|
|
79
|
+
|
|
80
|
+
- **Working spec invalid**: Run `caws validate --suggestions`
|
|
81
|
+
- **Scope violations**: Update `.caws/working-spec.yaml` scope or create waiver
|
|
82
|
+
- **Quality gate failures**: Address root cause rather than creating waivers
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Junie Guidelines - CAWS Project
|
|
2
|
+
|
|
3
|
+
This project uses CAWS (Coding Agent Working Standard) for quality-assured development.
|
|
4
|
+
|
|
5
|
+
## Working Spec
|
|
6
|
+
|
|
7
|
+
Before making changes, read `.caws/working-spec.yaml`. It defines:
|
|
8
|
+
|
|
9
|
+
- **Risk tier**: Quality requirements (T1: 90%+ coverage, T2: 80%+, T3: 70%+)
|
|
10
|
+
- **Scope**: `scope.in` lists files you may edit, `scope.out` is off-limits
|
|
11
|
+
- **Change budget**: Maximum files and lines of code per change
|
|
12
|
+
- **Acceptance criteria**: What "done" means for this task
|
|
13
|
+
|
|
14
|
+
## CAWS Commands
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
caws validate # Validate the working spec
|
|
18
|
+
caws agent iterate # Get implementation guidance
|
|
19
|
+
caws agent evaluate # Evaluate quality compliance
|
|
20
|
+
caws waivers create --reason ... # Create waiver for justified exceptions
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Key Rules
|
|
24
|
+
|
|
25
|
+
1. **Stay in scope** -- only edit files listed in `scope.in`
|
|
26
|
+
2. **Respect change budgets** -- stay within `max_files` and `max_loc`
|
|
27
|
+
3. **No shadow files** -- edit in place, never create `*-enhanced.*`, `*-new.*`, `*-v2.*`, `*-final.*` copies
|
|
28
|
+
4. **Tests first** -- write failing tests before implementation
|
|
29
|
+
5. **Deterministic code** -- inject time, random, and UUID generators for testability
|
|
30
|
+
6. **No fake implementations** -- no placeholder stubs, no `TODO` in committed code, no in-memory arrays pretending to be persistence, no hardcoded mock responses
|
|
31
|
+
7. **Prove claims** -- never assert "production-ready", "complete", or "battle-tested" without passing all quality gates. Provide evidence, not assertions.
|
|
32
|
+
8. **No marketing language in docs** -- avoid "revolutionary", "cutting-edge", "state-of-the-art", "enterprise-grade"
|
|
33
|
+
9. **Ask first for risky changes** -- changes touching >10 files, >300 LOC, crossing package boundaries, or affecting security/infrastructure require discussion first
|
|
34
|
+
10. **Conventional commits** -- use `feat:`, `fix:`, `refactor:`, `docs:`, `chore:` prefixes
|
|
35
|
+
|
|
36
|
+
## Quality Gates
|
|
37
|
+
|
|
38
|
+
| Gate | T1 (Critical) | T2 (Standard) | T3 (Low Risk) |
|
|
39
|
+
|------|---------------|----------------|----------------|
|
|
40
|
+
| Test coverage | 90%+ | 80%+ | 70%+ |
|
|
41
|
+
| Mutation score | 70%+ | 50%+ | 30%+ |
|
|
42
|
+
| Contracts | Required | Required | Optional |
|
|
43
|
+
| Manual review | Required | Optional | Optional |
|
|
44
|
+
|
|
45
|
+
## Code Style
|
|
46
|
+
|
|
47
|
+
- Prefer `const` over `let`
|
|
48
|
+
- Use guard clauses and early returns over deep nesting
|
|
49
|
+
- Single responsibility: one reason to change per module
|
|
50
|
+
- Depend on abstractions, not concretions
|
|
51
|
+
- Extension points over editing internals (open/closed principle)
|
|
52
|
+
- Max cyclomatic complexity per function: 10
|
|
53
|
+
- Max cognitive complexity: 15
|
|
54
|
+
- Max nesting depth: 4
|
|
55
|
+
- Max function length: 50 lines
|
|
56
|
+
- Max file length: 1000 lines
|
|
57
|
+
- Max parameters: 5
|
|
58
|
+
- No emojis in production code or logs
|
|
59
|
+
- Check if a server/process is already running before starting another
|
|
60
|
+
|
|
61
|
+
### Naming
|
|
62
|
+
|
|
63
|
+
Forbidden file name modifiers: enhanced, unified, better, new, next, final, copy, revamp, improved. Prefer in-place edits with a merge-then-delete strategy for refactors.
|
|
64
|
+
|
|
65
|
+
## Build & Test
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install # Install dependencies
|
|
69
|
+
npm test # Run tests
|
|
70
|
+
npm run lint # Lint code
|
|
71
|
+
npm run typecheck # Type check (if TypeScript)
|
|
72
|
+
caws validate # Validate CAWS spec
|
|
73
|
+
```
|
|
@@ -1,33 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.2.0",
|
|
3
3
|
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"name": "Run CAWS Extension",
|
|
6
|
-
"type": "extensionHost",
|
|
7
|
-
"request": "launch",
|
|
8
|
-
"args": ["--extensionDevelopmentPath=${workspaceFolder}/packages/caws-vscode-extension"],
|
|
9
|
-
"outFiles": ["${workspaceFolder}/packages/caws-vscode-extension/out/**/*.js"],
|
|
10
|
-
"preLaunchTask": "${workspaceFolder}/packages/caws-vscode-extension:watch"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"name": "Run CAWS Extension (Host Workspace)",
|
|
14
|
-
"type": "extensionHost",
|
|
15
|
-
"request": "launch",
|
|
16
|
-
"args": ["--extensionDevelopmentPath=${workspaceFolder}/packages/caws-vscode-extension", "${workspaceFolder}"],
|
|
17
|
-
"outFiles": ["${workspaceFolder}/packages/caws-vscode-extension/out/**/*.js"],
|
|
18
|
-
"preLaunchTask": "${workspaceFolder}/packages/caws-vscode-extension:watch"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"name": "Debug CAWS Extension",
|
|
22
|
-
"type": "node",
|
|
23
|
-
"request": "launch",
|
|
24
|
-
"program": "${workspaceFolder}/packages/caws-vscode-extension/out/extension.js",
|
|
25
|
-
"args": ["--inspect=6009"],
|
|
26
|
-
"env": {
|
|
27
|
-
"CAWS_DEBUG": "true"
|
|
28
|
-
},
|
|
29
|
-
"preLaunchTask": "${workspaceFolder}/packages/caws-vscode-extension:compile"
|
|
30
|
-
},
|
|
31
4
|
{
|
|
32
5
|
"name": "Debug MCP Server",
|
|
33
6
|
"type": "node",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# CAWS Quality Standards
|
|
2
|
+
|
|
3
|
+
This project uses CAWS (Coding Agent Working Standard) for quality-assured development.
|
|
4
|
+
|
|
5
|
+
## Working Spec
|
|
6
|
+
|
|
7
|
+
Always check `.caws/working-spec.yaml` before making changes. It defines:
|
|
8
|
+
|
|
9
|
+
- **Risk tier**: T1 (critical, 90%+ coverage), T2 (standard, 80%+), T3 (low risk, 70%+)
|
|
10
|
+
- **Scope boundaries**: `scope.in` (allowed files), `scope.out` (off-limits)
|
|
11
|
+
- **Change budget**: `max_files` and `max_loc` limits per change
|
|
12
|
+
- **Acceptance criteria**: Definition of done
|
|
13
|
+
|
|
14
|
+
## Key Rules
|
|
15
|
+
|
|
16
|
+
1. Stay within scope boundaries defined in the working spec
|
|
17
|
+
2. Respect change budgets -- split large changes into smaller PRs
|
|
18
|
+
3. No shadow files: never create `*-enhanced.*`, `*-new.*`, `*-v2.*`, `*-final.*` copies
|
|
19
|
+
4. Write tests before implementation when possible
|
|
20
|
+
5. Deterministic code -- inject time, random, and UUID generators for testability
|
|
21
|
+
6. No fake implementations -- no placeholder stubs, no `TODO` in committed code, no in-memory arrays pretending to be persistence, no hardcoded mock responses
|
|
22
|
+
7. Prove claims -- never assert "production-ready", "complete", or "battle-tested" without passing all quality gates. Provide evidence, not assertions.
|
|
23
|
+
8. No marketing language in docs -- avoid "revolutionary", "cutting-edge", "state-of-the-art", "enterprise-grade"
|
|
24
|
+
9. Ask first for risky changes -- changes touching >10 files, >300 LOC, crossing package boundaries, or affecting security/infrastructure require discussion first
|
|
25
|
+
10. Use conventional commits: `feat:`, `fix:`, `refactor:`, `docs:`, `chore:`
|
|
26
|
+
11. Run `caws validate` before committing
|
|
27
|
+
|
|
28
|
+
## Quality Commands
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
caws validate # Validate working spec
|
|
32
|
+
caws agent iterate # Get implementation guidance
|
|
33
|
+
caws agent evaluate # Evaluate quality compliance
|
|
34
|
+
caws waivers create --reason ... # Create waiver for justified exceptions
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Code Style
|
|
38
|
+
|
|
39
|
+
- Prefer `const` over `let`
|
|
40
|
+
- Use guard clauses and early returns over deep nesting
|
|
41
|
+
- Single responsibility: one reason to change per module
|
|
42
|
+
- Depend on abstractions, not concretions
|
|
43
|
+
- Extension points over editing internals (open/closed principle)
|
|
44
|
+
- Max cyclomatic complexity per function: 10
|
|
45
|
+
- Max nesting depth: 4
|
|
46
|
+
- Max function length: 50 lines
|
|
47
|
+
- Max file length: 1000 lines
|
|
48
|
+
- Max parameters: 5
|
|
49
|
+
- No emojis in production code or logs
|
|
50
|
+
- Check if a server/process is already running before starting another
|
|
51
|
+
|
|
52
|
+
## Naming
|
|
53
|
+
|
|
54
|
+
Forbidden file name modifiers: enhanced, unified, better, new, next, final, copy, revamp, improved. Use in-place edits with merge-then-delete strategy for refactors.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This project uses CAWS (Coding Agent Working Standard) for quality-assured AI-assisted development.
|
|
4
|
+
|
|
5
|
+
## Build & Test
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install dependencies
|
|
9
|
+
npm install
|
|
10
|
+
|
|
11
|
+
# Run tests
|
|
12
|
+
npm test
|
|
13
|
+
|
|
14
|
+
# Lint
|
|
15
|
+
npm run lint
|
|
16
|
+
|
|
17
|
+
# Type check (if TypeScript)
|
|
18
|
+
npm run typecheck
|
|
19
|
+
|
|
20
|
+
# Run all quality gates
|
|
21
|
+
caws validate
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## CAWS Workflow
|
|
25
|
+
|
|
26
|
+
Before writing code, check the working spec:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Validate the working spec
|
|
30
|
+
caws validate
|
|
31
|
+
|
|
32
|
+
# Get iteration guidance
|
|
33
|
+
caws agent iterate --current-state "describe what you're about to do"
|
|
34
|
+
|
|
35
|
+
# After implementation, evaluate quality
|
|
36
|
+
caws agent evaluate
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Working Spec
|
|
40
|
+
|
|
41
|
+
The project spec lives at `.caws/working-spec.yaml`. It defines:
|
|
42
|
+
|
|
43
|
+
- **Risk tier**: Quality requirements (T1: critical, T2: standard, T3: low risk)
|
|
44
|
+
- **Scope**: Which files you can edit (`scope.in`) and which are off-limits (`scope.out`)
|
|
45
|
+
- **Change budget**: Max files and lines of code per change
|
|
46
|
+
- **Acceptance criteria**: What "done" means
|
|
47
|
+
|
|
48
|
+
Always stay within scope boundaries and change budgets.
|
|
49
|
+
|
|
50
|
+
### Quality Gates
|
|
51
|
+
|
|
52
|
+
Quality requirements are tiered:
|
|
53
|
+
|
|
54
|
+
| Gate | T1 (Critical) | T2 (Standard) | T3 (Low Risk) |
|
|
55
|
+
|------|---------------|----------------|----------------|
|
|
56
|
+
| Test coverage | 90%+ | 80%+ | 70%+ |
|
|
57
|
+
| Mutation score | 70%+ | 50%+ | 30%+ |
|
|
58
|
+
| Contracts | Required | Required | Optional |
|
|
59
|
+
| Manual review | Required | Optional | Optional |
|
|
60
|
+
|
|
61
|
+
### Key Rules
|
|
62
|
+
|
|
63
|
+
1. **Stay in scope** -- only edit files listed in `scope.in`, never touch `scope.out`
|
|
64
|
+
2. **Respect change budgets** -- stay within `max_files` and `max_loc` limits
|
|
65
|
+
3. **No shadow files** -- edit in place, never create `*-enhanced.*`, `*-new.*`, `*-v2.*`, `*-final.*` copies
|
|
66
|
+
4. **Tests first** -- write failing tests before implementation
|
|
67
|
+
5. **Deterministic code** -- inject time, random, and UUID generators for testability
|
|
68
|
+
6. **No fake implementations** -- no placeholder stubs, no `TODO` in committed code, no in-memory arrays pretending to be persistence, no hardcoded mock responses
|
|
69
|
+
7. **Prove claims** -- never assert "production-ready", "complete", or "battle-tested" without passing all quality gates. Provide evidence, not assertions.
|
|
70
|
+
8. **No marketing language in docs** -- avoid "revolutionary", "cutting-edge", "state-of-the-art", "enterprise-grade"
|
|
71
|
+
9. **Ask first for risky changes** -- changes touching >10 files, >300 LOC, crossing package boundaries, or affecting security/infrastructure require discussion first
|
|
72
|
+
10. **Conventional commits** -- use `feat:`, `fix:`, `refactor:`, `docs:`, `chore:` prefixes
|
|
73
|
+
|
|
74
|
+
### Waivers
|
|
75
|
+
|
|
76
|
+
If you need to bypass a quality gate, create a waiver with justification:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
caws waivers create --reason emergency_hotfix --gates coverage_threshold
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Valid reasons: `emergency_hotfix`, `legacy_integration`, `experimental_feature`, `performance_critical`, `infrastructure_limitation`
|
|
83
|
+
|
|
84
|
+
## Project Structure
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
.caws/
|
|
88
|
+
working-spec.yaml # Project spec (risk tier, scope, acceptance criteria)
|
|
89
|
+
policy.yaml # Quality policy overrides (optional)
|
|
90
|
+
waivers.yml # Active waivers
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Hooks
|
|
94
|
+
|
|
95
|
+
This project has Claude Code hooks configured in `.claude/settings.json`:
|
|
96
|
+
|
|
97
|
+
- **PreToolUse**: Blocks dangerous commands, scans for secrets, enforces scope
|
|
98
|
+
- **PostToolUse**: Runs quality checks, validates spec, checks naming conventions
|
|
99
|
+
- **Session**: Audit logging for provenance tracking
|
|
100
|
+
|
|
101
|
+
See `.claude/README.md` for hook details.
|