safeword 0.2.3 → 0.2.4
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/.claude/commands/arch-review.md +32 -0
- package/.claude/commands/lint.md +6 -0
- package/.claude/commands/quality-review.md +13 -0
- package/.claude/commands/setup-linting.md +6 -0
- package/.claude/hooks/auto-lint.sh +6 -0
- package/.claude/hooks/auto-quality-review.sh +170 -0
- package/.claude/hooks/check-linting-sync.sh +17 -0
- package/.claude/hooks/inject-timestamp.sh +6 -0
- package/.claude/hooks/question-protocol.sh +12 -0
- package/.claude/hooks/run-linters.sh +8 -0
- package/.claude/hooks/run-quality-review.sh +76 -0
- package/.claude/hooks/version-check.sh +10 -0
- package/.claude/mcp/README.md +96 -0
- package/.claude/mcp/arcade.sample.json +9 -0
- package/.claude/mcp/context7.sample.json +7 -0
- package/.claude/mcp/playwright.sample.json +7 -0
- package/.claude/settings.json +62 -0
- package/.claude/skills/quality-reviewer/SKILL.md +190 -0
- package/.claude/skills/safeword-quality-reviewer/SKILL.md +13 -0
- package/.env.arcade.example +4 -0
- package/.env.example +11 -0
- package/.gitmodules +4 -0
- package/.safeword/SAFEWORD.md +33 -0
- package/.safeword/eslint/eslint-base.mjs +101 -0
- package/.safeword/guides/architecture-guide.md +404 -0
- package/.safeword/guides/code-philosophy.md +174 -0
- package/.safeword/guides/context-files-guide.md +405 -0
- package/.safeword/guides/data-architecture-guide.md +183 -0
- package/.safeword/guides/design-doc-guide.md +165 -0
- package/.safeword/guides/learning-extraction.md +515 -0
- package/.safeword/guides/llm-instruction-design.md +239 -0
- package/.safeword/guides/llm-prompting.md +95 -0
- package/.safeword/guides/tdd-best-practices.md +570 -0
- package/.safeword/guides/test-definitions-guide.md +243 -0
- package/.safeword/guides/testing-methodology.md +573 -0
- package/.safeword/guides/user-story-guide.md +237 -0
- package/.safeword/guides/zombie-process-cleanup.md +214 -0
- package/{templates → .safeword}/hooks/agents-md-check.sh +0 -0
- package/{templates → .safeword}/hooks/post-tool.sh +0 -0
- package/{templates → .safeword}/hooks/pre-commit.sh +0 -0
- package/.safeword/planning/002-user-story-quality-evaluation.md +1840 -0
- package/.safeword/planning/003-langsmith-eval-setup-prompt.md +363 -0
- package/.safeword/planning/004-llm-eval-test-cases.md +3226 -0
- package/.safeword/planning/005-architecture-enforcement-system.md +169 -0
- package/.safeword/planning/006-reactive-fix-prevention-research.md +135 -0
- package/.safeword/planning/011-cli-ux-vision.md +330 -0
- package/.safeword/planning/012-project-structure-cleanup.md +154 -0
- package/.safeword/planning/README.md +39 -0
- package/.safeword/planning/automation-plan-v2.md +1225 -0
- package/.safeword/planning/automation-plan-v3.md +1291 -0
- package/.safeword/planning/automation-plan.md +3058 -0
- package/.safeword/planning/design/005-cli-implementation.md +343 -0
- package/.safeword/planning/design/013-cli-self-contained-templates.md +596 -0
- package/.safeword/planning/design/013a-eslint-plugin-suite.md +256 -0
- package/.safeword/planning/design/013b-implementation-snippets.md +385 -0
- package/.safeword/planning/design/013c-config-isolation-strategy.md +242 -0
- package/.safeword/planning/design/code-philosophy-improvements.md +60 -0
- package/.safeword/planning/mcp-analysis.md +545 -0
- package/.safeword/planning/phase2-subagents-vs-skills-analysis.md +451 -0
- package/.safeword/planning/settings-improvements.md +970 -0
- package/.safeword/planning/test-definitions/005-cli-implementation.md +1301 -0
- package/.safeword/planning/test-definitions/cli-self-contained-templates.md +205 -0
- package/.safeword/planning/user-stories/001-guides-review-user-stories.md +1381 -0
- package/.safeword/planning/user-stories/003-reactive-fix-prevention.md +132 -0
- package/.safeword/planning/user-stories/004-technical-constraints.md +86 -0
- package/.safeword/planning/user-stories/005-cli-implementation.md +311 -0
- package/.safeword/planning/user-stories/cli-self-contained-templates.md +172 -0
- package/.safeword/planning/versioned-distribution.md +740 -0
- package/.safeword/prompts/arch-review.md +43 -0
- package/.safeword/prompts/quality-review.md +11 -0
- package/.safeword/scripts/arch-review.sh +235 -0
- package/.safeword/scripts/check-linting-sync.sh +58 -0
- package/.safeword/scripts/setup-linting.sh +559 -0
- package/.safeword/templates/architecture-template.md +136 -0
- package/.safeword/templates/ci/architecture-check.yml +79 -0
- package/.safeword/templates/design-doc-template.md +127 -0
- package/.safeword/templates/test-definitions-feature.md +100 -0
- package/.safeword/templates/ticket-template.md +74 -0
- package/.safeword/templates/user-stories-template.md +82 -0
- package/.safeword/tickets/001-guides-review-user-stories.md +83 -0
- package/.safeword/tickets/002-architecture-enforcement.md +211 -0
- package/.safeword/tickets/003-reactive-fix-prevention.md +57 -0
- package/.safeword/tickets/004-technical-constraints-in-user-stories.md +39 -0
- package/.safeword/tickets/005-cli-implementation.md +248 -0
- package/.safeword/tickets/006-flesh-out-skills.md +43 -0
- package/.safeword/tickets/007-flesh-out-questioning.md +44 -0
- package/.safeword/tickets/008-upgrade-questioning.md +58 -0
- package/.safeword/tickets/009-naming-conventions.md +41 -0
- package/.safeword/tickets/010-safeword-md-cleanup.md +34 -0
- package/.safeword/tickets/011-cursor-setup.md +86 -0
- package/.safeword/tickets/README.md +73 -0
- package/.safeword/version +1 -0
- package/AGENTS.md +59 -0
- package/CLAUDE.md +12 -0
- package/README.md +347 -0
- package/docs/001-cli-implementation-plan.md +856 -0
- package/docs/elite-dx-implementation-plan.md +1034 -0
- package/framework/README.md +131 -0
- package/framework/mcp/README.md +96 -0
- package/framework/mcp/arcade.sample.json +8 -0
- package/framework/mcp/context7.sample.json +6 -0
- package/framework/mcp/playwright.sample.json +6 -0
- package/framework/scripts/arch-review.sh +235 -0
- package/framework/scripts/check-linting-sync.sh +58 -0
- package/framework/scripts/load-env.sh +49 -0
- package/framework/scripts/setup-claude.sh +223 -0
- package/framework/scripts/setup-linting.sh +559 -0
- package/framework/scripts/setup-quality.sh +477 -0
- package/framework/scripts/setup-safeword.sh +550 -0
- package/framework/templates/ci/architecture-check.yml +78 -0
- package/learnings/ai-sdk-v5-breaking-changes.md +178 -0
- package/learnings/e2e-test-zombie-processes.md +231 -0
- package/learnings/milkdown-crepe-editor-property.md +96 -0
- package/learnings/prosemirror-fragment-traversal.md +119 -0
- package/package.json +19 -43
- package/packages/cli/AGENTS.md +1 -0
- package/packages/cli/ARCHITECTURE.md +279 -0
- package/packages/cli/package.json +51 -0
- package/packages/cli/src/cli.ts +63 -0
- package/packages/cli/src/commands/check.ts +166 -0
- package/packages/cli/src/commands/diff.ts +209 -0
- package/packages/cli/src/commands/reset.ts +190 -0
- package/packages/cli/src/commands/setup.ts +325 -0
- package/packages/cli/src/commands/upgrade.ts +163 -0
- package/packages/cli/src/index.ts +3 -0
- package/packages/cli/src/templates/config.ts +58 -0
- package/packages/cli/src/templates/content.ts +18 -0
- package/packages/cli/src/templates/index.ts +12 -0
- package/packages/cli/src/utils/agents-md.ts +66 -0
- package/packages/cli/src/utils/fs.ts +179 -0
- package/packages/cli/src/utils/git.ts +124 -0
- package/packages/cli/src/utils/hooks.ts +29 -0
- package/packages/cli/src/utils/output.ts +60 -0
- package/packages/cli/src/utils/project-detector.test.ts +185 -0
- package/packages/cli/src/utils/project-detector.ts +44 -0
- package/packages/cli/src/utils/version.ts +28 -0
- package/packages/cli/src/version.ts +6 -0
- package/packages/cli/templates/SAFEWORD.md +776 -0
- package/packages/cli/templates/doc-templates/architecture-template.md +136 -0
- package/packages/cli/templates/doc-templates/design-doc-template.md +134 -0
- package/packages/cli/templates/doc-templates/test-definitions-feature.md +131 -0
- package/packages/cli/templates/doc-templates/ticket-template.md +82 -0
- package/packages/cli/templates/doc-templates/user-stories-template.md +92 -0
- package/packages/cli/templates/guides/architecture-guide.md +423 -0
- package/packages/cli/templates/guides/code-philosophy.md +195 -0
- package/packages/cli/templates/guides/context-files-guide.md +457 -0
- package/packages/cli/templates/guides/data-architecture-guide.md +200 -0
- package/packages/cli/templates/guides/design-doc-guide.md +171 -0
- package/packages/cli/templates/guides/learning-extraction.md +552 -0
- package/packages/cli/templates/guides/llm-instruction-design.md +248 -0
- package/packages/cli/templates/guides/llm-prompting.md +102 -0
- package/packages/cli/templates/guides/tdd-best-practices.md +615 -0
- package/packages/cli/templates/guides/test-definitions-guide.md +334 -0
- package/packages/cli/templates/guides/testing-methodology.md +618 -0
- package/packages/cli/templates/guides/user-story-guide.md +256 -0
- package/packages/cli/templates/guides/zombie-process-cleanup.md +219 -0
- package/packages/cli/templates/hooks/agents-md-check.sh +27 -0
- package/packages/cli/templates/hooks/post-tool.sh +4 -0
- package/packages/cli/templates/hooks/pre-commit.sh +10 -0
- package/packages/cli/templates/prompts/arch-review.md +43 -0
- package/packages/cli/templates/prompts/quality-review.md +10 -0
- package/packages/cli/templates/skills/safeword-quality-reviewer/SKILL.md +207 -0
- package/packages/cli/tests/commands/check.test.ts +129 -0
- package/packages/cli/tests/commands/cli.test.ts +89 -0
- package/packages/cli/tests/commands/diff.test.ts +115 -0
- package/packages/cli/tests/commands/reset.test.ts +310 -0
- package/packages/cli/tests/commands/self-healing.test.ts +170 -0
- package/packages/cli/tests/commands/setup-blocking.test.ts +71 -0
- package/packages/cli/tests/commands/setup-core.test.ts +135 -0
- package/packages/cli/tests/commands/setup-git.test.ts +139 -0
- package/packages/cli/tests/commands/setup-hooks.test.ts +334 -0
- package/packages/cli/tests/commands/setup-linting.test.ts +189 -0
- package/packages/cli/tests/commands/setup-noninteractive.test.ts +80 -0
- package/packages/cli/tests/commands/setup-templates.test.ts +181 -0
- package/packages/cli/tests/commands/upgrade.test.ts +215 -0
- package/packages/cli/tests/helpers.ts +243 -0
- package/packages/cli/tests/npm-package.test.ts +83 -0
- package/packages/cli/tests/technical-constraints.test.ts +96 -0
- package/packages/cli/tsconfig.json +25 -0
- package/packages/cli/tsup.config.ts +11 -0
- package/packages/cli/vitest.config.ts +23 -0
- package/promptfoo.yaml +3270 -0
- package/dist/check-3NGQ4NR5.js +0 -129
- package/dist/check-3NGQ4NR5.js.map +0 -1
- package/dist/chunk-2XWIUEQK.js +0 -190
- package/dist/chunk-2XWIUEQK.js.map +0 -1
- package/dist/chunk-GZRQL3SX.js +0 -146
- package/dist/chunk-GZRQL3SX.js.map +0 -1
- package/dist/chunk-ORQHKDT2.js +0 -10
- package/dist/chunk-ORQHKDT2.js.map +0 -1
- package/dist/chunk-W66Z3C5H.js +0 -21
- package/dist/chunk-W66Z3C5H.js.map +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -34
- package/dist/cli.js.map +0 -1
- package/dist/diff-Y6QTAW4O.js +0 -166
- package/dist/diff-Y6QTAW4O.js.map +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/reset-3ACTIYYE.js +0 -143
- package/dist/reset-3ACTIYYE.js.map +0 -1
- package/dist/setup-RR4M334C.js +0 -266
- package/dist/setup-RR4M334C.js.map +0 -1
- package/dist/upgrade-6AR3DHUV.js +0 -134
- package/dist/upgrade-6AR3DHUV.js.map +0 -1
- /package/{templates → framework}/SAFEWORD.md +0 -0
- /package/{templates → framework}/guides/architecture-guide.md +0 -0
- /package/{templates → framework}/guides/code-philosophy.md +0 -0
- /package/{templates → framework}/guides/context-files-guide.md +0 -0
- /package/{templates → framework}/guides/data-architecture-guide.md +0 -0
- /package/{templates → framework}/guides/design-doc-guide.md +0 -0
- /package/{templates → framework}/guides/learning-extraction.md +0 -0
- /package/{templates → framework}/guides/llm-instruction-design.md +0 -0
- /package/{templates → framework}/guides/llm-prompting.md +0 -0
- /package/{templates → framework}/guides/tdd-best-practices.md +0 -0
- /package/{templates → framework}/guides/test-definitions-guide.md +0 -0
- /package/{templates → framework}/guides/testing-methodology.md +0 -0
- /package/{templates → framework}/guides/user-story-guide.md +0 -0
- /package/{templates → framework}/guides/zombie-process-cleanup.md +0 -0
- /package/{templates → framework}/prompts/arch-review.md +0 -0
- /package/{templates → framework}/prompts/quality-review.md +0 -0
- /package/{templates/skills/safeword-quality-reviewer → framework/skills/quality-reviewer}/SKILL.md +0 -0
- /package/{templates/doc-templates → framework/templates}/architecture-template.md +0 -0
- /package/{templates/doc-templates → framework/templates}/design-doc-template.md +0 -0
- /package/{templates/doc-templates → framework/templates}/test-definitions-feature.md +0 -0
- /package/{templates/doc-templates → framework/templates}/ticket-template.md +0 -0
- /package/{templates/doc-templates → framework/templates}/user-stories-template.md +0 -0
- /package/{templates → packages/cli/templates}/commands/arch-review.md +0 -0
- /package/{templates → packages/cli/templates}/commands/lint.md +0 -0
- /package/{templates → packages/cli/templates}/commands/quality-review.md +0 -0
- /package/{templates → packages/cli/templates}/hooks/inject-timestamp.sh +0 -0
- /package/{templates → packages/cli/templates}/lib/common.sh +0 -0
- /package/{templates → packages/cli/templates}/lib/jq-fallback.sh +0 -0
- /package/{templates → packages/cli/templates}/markdownlint.jsonc +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
# SAFEWORD - Claude Code Framework
|
|
2
|
+
|
|
3
|
+
**Problem**: AI agents write code without tests, skip design validation, and lack consistency across projects.
|
|
4
|
+
|
|
5
|
+
**Solution**: Portable patterns and guides that enforce TDD workflow, quality standards, and best practices across all your projects.
|
|
6
|
+
|
|
7
|
+
**Repository**: https://github.com/TheMostlyGreat/safeword (private)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Quick Start (30 seconds)
|
|
12
|
+
|
|
13
|
+
**1. Install in your project:**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd /path/to/your/project
|
|
17
|
+
bash ./framework/scripts/setup-safeword.sh
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**2. Verify installation:**
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Check for SAFEWORD files and hooks
|
|
24
|
+
test -f .safeword/SAFEWORD.md && echo ".safeword/SAFEWORD.md ✓"
|
|
25
|
+
test -f .claude/settings.json && echo ".claude/settings.json ✓"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Result**: Your project now has:
|
|
29
|
+
|
|
30
|
+
- `.safeword/SAFEWORD.md` - Global patterns and workflows
|
|
31
|
+
- `.safeword/guides/` - TDD methodology, testing, code philosophy
|
|
32
|
+
- `.claude/hooks/` - Auto-linting and quality review
|
|
33
|
+
- `SAFEWORD.md` or `CLAUDE.md` - Project context with framework reference
|
|
34
|
+
|
|
35
|
+
**Commit these to your repo** for team consistency.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## How It Works
|
|
40
|
+
|
|
41
|
+
**Project-local framework**: Scripts write to `.safeword/` and `.claude/` in your project (no global install needed)
|
|
42
|
+
|
|
43
|
+
**Team consistency**: Teammates get the framework from your project repo (no global install needed)
|
|
44
|
+
|
|
45
|
+
**Living documentation**: Update guides as you learn, extract learnings from debugging, archive completed work
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## What's Inside
|
|
50
|
+
|
|
51
|
+
Key directories created in your project:
|
|
52
|
+
|
|
53
|
+
- `.safeword/guides/` - Core methodology and best practices
|
|
54
|
+
- `.safeword/templates/` - Fillable document structures
|
|
55
|
+
- `.safeword/planning/` - Planning documentation (user-stories, test-definitions, design, issues)
|
|
56
|
+
- `.claude/hooks/` - Automation scripts
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Core Guides
|
|
61
|
+
|
|
62
|
+
**Purpose**: Reusable methodology applicable to all projects
|
|
63
|
+
|
|
64
|
+
| Guide | Purpose | When to Read |
|
|
65
|
+
| -------------------------- | --------------------------------------------------------------- | ----------------------- |
|
|
66
|
+
| **code-philosophy.md** | Core coding principles, TDD philosophy, self-review checklist | Before writing code |
|
|
67
|
+
| **testing-methodology.md** | TDD workflow (RED/GREEN/REFACTOR), test pyramid, decision trees | Starting any feature |
|
|
68
|
+
| **tdd-best-practices.md** | User story + test definition patterns and examples | Creating tests/stories |
|
|
69
|
+
| **learning-extraction.md** | Extract learnings from debugging, recognition triggers | After complex debugging |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Documentation Guides
|
|
74
|
+
|
|
75
|
+
**Purpose**: Writing effective feature documentation
|
|
76
|
+
|
|
77
|
+
| Guide | Purpose | When to Read |
|
|
78
|
+
| ------------------------------ | -------------------------------------------------- | ------------------------------ |
|
|
79
|
+
| **user-story-guide.md** | Writing effective user stories (INVEST criteria) | Creating user stories |
|
|
80
|
+
| **test-definitions-guide.md** | Writing test definitions (unit/integration/E2E) | Planning test suites |
|
|
81
|
+
| **design-doc-guide.md** | Design doc structure and best practices | Designing complex features |
|
|
82
|
+
| **architecture-guide.md** | Architecture decisions (tech choices, data models) | Making architectural decisions |
|
|
83
|
+
| **data-architecture-guide.md** | Data model design (schemas, validation, flows) | Database/schema design |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Meta Guides
|
|
88
|
+
|
|
89
|
+
**Purpose**: Working with LLMs and documentation structure
|
|
90
|
+
|
|
91
|
+
| Guide | Purpose | When to Read |
|
|
92
|
+
| ----------------------------- | ------------------------------------------------------------------------ | --------------------------- |
|
|
93
|
+
| **llm-prompting.md** | Prompt engineering, LLM cost optimization, caching | Building AI features |
|
|
94
|
+
| **llm-instruction-design.md** | 13 principles for LLM-consumable docs (MECE, examples) | Creating SAFEWORD.md/guides |
|
|
95
|
+
| **context-files-guide.md** | CLAUDE.md/CURSOR.md/AGENTS.md structure, anti-patterns, modular approach | Setting up projects |
|
|
96
|
+
| **zombie-process-cleanup.md** | Port-based cleanup, multi-project isolation | Managing dev servers |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Templates
|
|
101
|
+
|
|
102
|
+
**Purpose**: Fillable structures for feature documentation
|
|
103
|
+
|
|
104
|
+
| Template | Purpose | Used By |
|
|
105
|
+
| ------------------------------- | ------------------------------------------------ | ------------------------- |
|
|
106
|
+
| **user-stories-template.md** | User story structure (As a X / Given-When-Then) | user-story-guide.md |
|
|
107
|
+
| **test-definitions-feature.md** | Test definition structure (suites, tests, steps) | test-definitions-guide.md |
|
|
108
|
+
| **design-doc-template.md** | Design doc structure (architecture, components) | design-doc-guide.md |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Learnings
|
|
113
|
+
|
|
114
|
+
**Purpose**: Extracted knowledge that compounds across sessions
|
|
115
|
+
|
|
116
|
+
**Location**: `.safeword/learnings/[concept].md`
|
|
117
|
+
|
|
118
|
+
**What goes here**:
|
|
119
|
+
|
|
120
|
+
- Debugging discoveries (non-obvious gotchas, integration struggles)
|
|
121
|
+
- Trial-and-error findings (tried 3+ approaches before right one)
|
|
122
|
+
- Architecture insights (discovered during implementation)
|
|
123
|
+
- Testing traps (tests pass but UX broken, or vice versa)
|
|
124
|
+
|
|
125
|
+
**How to extract**: Follow `learning-extraction.md` recognition triggers and templates
|
|
126
|
+
|
|
127
|
+
**Example learnings**:
|
|
128
|
+
|
|
129
|
+
- React hooks async behavior
|
|
130
|
+
- Electron IPC patterns
|
|
131
|
+
- Browser storage quota quirks
|
|
132
|
+
- E2E test zombie processes
|
|
133
|
+
- ProseMirror fragment traversal
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Planning
|
|
138
|
+
|
|
139
|
+
**Purpose**: Feature planning and design documentation
|
|
140
|
+
|
|
141
|
+
**Structure**:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
planning/
|
|
145
|
+
├── user-stories/ User story documents
|
|
146
|
+
├── test-definitions/ Test definition documents
|
|
147
|
+
├── design/ Design docs and research
|
|
148
|
+
└── issues/ Issue capture and tracking
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Each directory has an `archive/` subfolder for completed work.
|
|
152
|
+
|
|
153
|
+
**What goes here**:
|
|
154
|
+
|
|
155
|
+
- User stories for features
|
|
156
|
+
- Test definitions for TDD workflow
|
|
157
|
+
- Design documents for complex features
|
|
158
|
+
- Research and analysis documents
|
|
159
|
+
- Issue tracking and capture
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Hooks & Skills
|
|
164
|
+
|
|
165
|
+
**Hooks**: Automation scripts triggered by Claude Code events
|
|
166
|
+
|
|
167
|
+
- `auto-quality-review.sh` - Automated quality control on responses
|
|
168
|
+
|
|
169
|
+
**Skills**: Specialized agent capabilities
|
|
170
|
+
|
|
171
|
+
- `quality-reviewer/` - Deep code quality review with web research
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Advanced Setup
|
|
176
|
+
|
|
177
|
+
### Custom Installation Options
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
cd /path/to/your/project
|
|
181
|
+
# SAFEWORD structure + (optionally) Claude Code hooks
|
|
182
|
+
bash ./framework/scripts/setup-safeword.sh
|
|
183
|
+
# Claude Code hooks only (if SAFEWORD already configured)
|
|
184
|
+
bash ./framework/scripts/setup-claude.sh --linting-mode biome
|
|
185
|
+
bash ./framework/scripts/setup-claude.sh --skip-linting
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Auto-detection**: Automatically detects project type from `package.json`:
|
|
189
|
+
|
|
190
|
+
- Biome → if `@biomejs/biome` installed
|
|
191
|
+
- Next.js → if `next` in dependencies
|
|
192
|
+
- Electron → if `electron` in dependencies
|
|
193
|
+
- Astro → if `astro` in dependencies
|
|
194
|
+
- React → if `react` in dependencies
|
|
195
|
+
- TypeScript → if `typescript` in dependencies or `tsconfig.json` exists
|
|
196
|
+
- Minimal → otherwise
|
|
197
|
+
|
|
198
|
+
### Reference Guides in Project SAFEWORD.md
|
|
199
|
+
|
|
200
|
+
```markdown
|
|
201
|
+
# Import guides from .safeword (SAFEWORD.md)
|
|
202
|
+
|
|
203
|
+
@./.safeword/guides/testing-methodology.md
|
|
204
|
+
@./.safeword/guides/code-philosophy.md
|
|
205
|
+
@./.safeword/guides/user-story-guide.md
|
|
206
|
+
@./.safeword/guides/test-definitions-guide.md
|
|
207
|
+
@./.safeword/guides/design-doc-guide.md
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Claude Code will auto-load these guides as context.
|
|
211
|
+
|
|
212
|
+
### Check for Existing Learnings
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# Project learnings (this repo)
|
|
216
|
+
ls .safeword/learnings/
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Extract New Learning
|
|
220
|
+
|
|
221
|
+
1. Follow recognition triggers in `learning-extraction.md`
|
|
222
|
+
2. Create `.safeword/learnings/[concept].md`
|
|
223
|
+
3. Use template: Problem → Gotcha → Examples → Testing Trap
|
|
224
|
+
|
|
225
|
+
### Create Planning Documentation
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# User stories
|
|
229
|
+
mkdir -p .safeword/planning/user-stories && touch .safeword/planning/user-stories/feature-name.md
|
|
230
|
+
# Test definitions
|
|
231
|
+
mkdir -p .safeword/planning/test-definitions && touch .safeword/planning/test-definitions/feature-name.md
|
|
232
|
+
# Design docs
|
|
233
|
+
mkdir -p .safeword/planning/design && touch .safeword/planning/design/feature-name.md
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Syncing Across Machines
|
|
239
|
+
|
|
240
|
+
Commit `.safeword/` and `.claude/` in your project repo for team consistency.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Integration with Project Context
|
|
245
|
+
|
|
246
|
+
**Project SAFEWORD.md/CLAUDE.md**: Created by `setup-safeword.sh` or manually, references `.safeword/SAFEWORD.md`
|
|
247
|
+
|
|
248
|
+
**How it works**:
|
|
249
|
+
|
|
250
|
+
1. Project SAFEWORD.md imports core guides via `@./.safeword/guides/`
|
|
251
|
+
2. Guides reference templates via `@./.safeword/templates/`
|
|
252
|
+
3. Guides cross-reference each other via `@./.safeword/guides/`
|
|
253
|
+
4. Learnings referenced via `ls .safeword/learnings/`
|
|
254
|
+
|
|
255
|
+
**Result**: Modular, maintainable documentation with clear separation of concerns
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Principles
|
|
260
|
+
|
|
261
|
+
1. **Guides** - Reusable methodology (test pyramid, TDD workflow)
|
|
262
|
+
2. **Templates** - Fillable structures (user stories, test definitions)
|
|
263
|
+
3. **Learnings** - Extracted knowledge (gotchas, discoveries)
|
|
264
|
+
4. **Planning** - Feature planning and design (user stories, test definitions, design docs)
|
|
265
|
+
5. **Hooks/Skills** - Automation and specialized capabilities
|
|
266
|
+
|
|
267
|
+
**Living Documentation**: Update as you learn, archive completed work, consolidate when needed
|
|
268
|
+
|
|
269
|
+
**Cross-Agent Compatible**: Works with Claude Code, Cursor, and other AI coding agents
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## LLM Eval Testing
|
|
274
|
+
|
|
275
|
+
**Purpose**: Validate that guides are effective for LLM consumption using promptfoo.
|
|
276
|
+
|
|
277
|
+
### Running Evals
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# Run all eval tests
|
|
281
|
+
npm run eval
|
|
282
|
+
|
|
283
|
+
# Run without cache (fresh API calls)
|
|
284
|
+
npm run eval:no-cache
|
|
285
|
+
|
|
286
|
+
# Open web UI to view results
|
|
287
|
+
npm run eval:view
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### What's Tested
|
|
291
|
+
|
|
292
|
+
The eval suite tests that LLMs correctly follow guide instructions:
|
|
293
|
+
|
|
294
|
+
| Category | Tests | What's Validated |
|
|
295
|
+
| ---------------------- | ------- | -------------------------------------------------------------------------------------- |
|
|
296
|
+
| Architecture | 21 | Doc type selection, layers, dependencies, ESLint, LLM review, pre-commit, CI, template |
|
|
297
|
+
| Code Philosophy | 14 | Bloat avoidance, error handling, TDD, self-review, git workflow |
|
|
298
|
+
| Testing Methodology | 13 | Test type selection, TDD phases, test integrity, cost controls |
|
|
299
|
+
| Zombie Process | 7 | Port-based cleanup, scripts, tmux isolation, best practices |
|
|
300
|
+
| User Stories | 13 | INVEST validation, size guidelines, templates, technical constraints |
|
|
301
|
+
| LLM Instruction Design | 15 | MECE trees, tie-breaking, lookup tables, anti-patterns |
|
|
302
|
+
| TDD Best Practices | 10 | Template selection, story formats, data builders |
|
|
303
|
+
| Design Doc | 10 | Prerequisites, template, components, user flow, decisions |
|
|
304
|
+
| Context Files | 11 | File selection, triggers, imports, size, cross-references |
|
|
305
|
+
| Data Architecture | 7 | Decision tree, principles, flows, policies, checklist |
|
|
306
|
+
| Learning Extraction | 11 | Triggers, templates, precedence, cross-references |
|
|
307
|
+
| LLM Prompting | 10 | Caching, structured outputs, LLM-as-judge, costs |
|
|
308
|
+
| Test Definitions | 12 | Suites, status, naming, mapping, LLM-friendly |
|
|
309
|
+
| **Total** | **154** | |
|
|
310
|
+
|
|
311
|
+
### Adding New Tests
|
|
312
|
+
|
|
313
|
+
Edit `promptfoo.yaml` and add a test case:
|
|
314
|
+
|
|
315
|
+
```yaml
|
|
316
|
+
- description: 'test-id: Description'
|
|
317
|
+
vars:
|
|
318
|
+
input: 'User prompt to test'
|
|
319
|
+
context: |
|
|
320
|
+
Relevant excerpt from guide
|
|
321
|
+
assert:
|
|
322
|
+
- type: llm-rubric
|
|
323
|
+
value: |
|
|
324
|
+
EXCELLENT: Best response criteria
|
|
325
|
+
ACCEPTABLE: Minimum passing criteria
|
|
326
|
+
POOR: Failing criteria
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Requirements
|
|
330
|
+
|
|
331
|
+
- `ANTHROPIC_API_KEY` environment variable set
|
|
332
|
+
- Tests use Claude Sonnet 4 by default
|
|
333
|
+
|
|
334
|
+
### Interpreting Results
|
|
335
|
+
|
|
336
|
+
- **PASS**: LLM followed guide correctly
|
|
337
|
+
- **FAIL**: Guide may need improvement (clearer instructions, examples, tie-breakers)
|
|
338
|
+
|
|
339
|
+
Results saved to `eval-results.json` after each run.
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Getting Help
|
|
344
|
+
|
|
345
|
+
- **Claude Code docs**: https://docs.claude.com/en/docs/claude-code
|
|
346
|
+
- **Issues**: https://github.com/anthropics/claude-code/issues
|
|
347
|
+
- **This repo**: https://github.com/TheMostlyGreat/safeword (private)
|