moai-adk 0.4.5__py3-none-any.whl → 0.4.8__py3-none-any.whl
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.
Potentially problematic release.
This version of moai-adk might be problematic. Click here for more details.
- moai_adk/__init__.py +1 -1
- moai_adk/core/project/initializer.py +12 -5
- moai_adk/templates/.claude/agents/alfred/cc-manager.md +188 -954
- moai_adk/templates/.claude/agents/alfred/debug-helper.md +4 -5
- moai_adk/templates/.claude/agents/alfred/doc-syncer.md +2 -2
- moai_adk/templates/.claude/agents/alfred/git-manager.md +2 -2
- moai_adk/templates/.claude/agents/alfred/implementation-planner.md +3 -3
- moai_adk/templates/.claude/agents/alfred/project-manager.md +6 -6
- moai_adk/templates/.claude/agents/alfred/quality-gate.md +4 -6
- moai_adk/templates/.claude/agents/alfred/skill-factory.md +829 -0
- moai_adk/templates/.claude/agents/alfred/spec-builder.md +2 -2
- moai_adk/templates/.claude/agents/alfred/tag-agent.md +2 -2
- moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +3 -3
- moai_adk/templates/.claude/agents/alfred/trust-checker.md +5 -5
- moai_adk/templates/.claude/commands/alfred/0-project.md +98 -42
- moai_adk/templates/.claude/commands/alfred/1-plan.md +7 -7
- moai_adk/templates/.claude/commands/alfred/2-run.md +36 -36
- moai_adk/templates/.claude/commands/alfred/3-sync.md +10 -10
- moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +14 -1
- moai_adk/templates/.claude/hooks/alfred/core/__init__.py +115 -33
- moai_adk/templates/.claude/hooks/alfred/handlers/session.py +8 -9
- moai_adk/templates/.claude/hooks/alfred/handlers/tool.py +6 -6
- moai_adk/templates/.claude/hooks/alfred/handlers/user.py +5 -4
- moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +1 -1
- moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +1 -1
- moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +1 -1
- moai_adk/templates/.claude/settings.json +42 -2
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +76 -66
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +86 -59
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/reference.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/SKILL.md +480 -0
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/examples.md +257 -0
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/reference.md +120 -0
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +87 -73
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +78 -62
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +78 -55
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +78 -64
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +249 -0
- moai_adk/templates/.claude/skills/moai-cc-agents/templates/agent-template.md +32 -0
- moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +278 -0
- moai_adk/templates/.claude/skills/moai-cc-claude-md/templates/CLAUDE-template.md +26 -0
- moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +287 -0
- moai_adk/templates/.claude/skills/moai-cc-commands/templates/command-template.md +21 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +232 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/pre-bash-check.sh +19 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/preserve-permissions.sh +19 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/validate-bash-command.py +24 -0
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +179 -0
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/templates/settings-mcp-template.json +39 -0
- moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +296 -0
- moai_adk/templates/.claude/skills/moai-cc-memory/templates/session-summary-template.md +18 -0
- moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +243 -0
- moai_adk/templates/.claude/skills/moai-cc-settings/templates/settings-complete-template.json +30 -0
- moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +271 -0
- moai_adk/templates/.claude/skills/moai-cc-skills/templates/SKILL-template.md +15 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +234 -43
- moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +1633 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +660 -0
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +97 -69
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +97 -72
- moai_adk/templates/.claude/skills/moai-domain-data-science/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-data-science/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +97 -74
- moai_adk/templates/.claude/skills/moai-domain-database/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-database/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-domain-devops/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-devops/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +98 -73
- moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +97 -73
- moai_adk/templates/.claude/skills/moai-domain-ml/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-ml/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +97 -67
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +97 -79
- moai_adk/templates/.claude/skills/moai-domain-security/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-security/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +97 -71
- moai_adk/templates/.claude/skills/moai-domain-web-api/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-domain-web-api/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +656 -60
- moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +1107 -0
- moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +1533 -0
- moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +87 -78
- moai_adk/templates/.claude/skills/moai-essentials-perf/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-essentials-perf/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +87 -70
- moai_adk/templates/.claude/skills/moai-essentials-refactor/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-essentials-refactor/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +87 -86
- moai_adk/templates/.claude/skills/moai-essentials-review/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-essentials-review/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +77 -62
- moai_adk/templates/.claude/skills/moai-foundation-ears/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-ears/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +88 -56
- moai_adk/templates/.claude/skills/moai-foundation-git/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-git/reference.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +90 -71
- moai_adk/templates/.claude/skills/moai-foundation-langs/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-langs/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +78 -58
- moai_adk/templates/.claude/skills/moai-foundation-specs/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-specs/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +78 -51
- moai_adk/templates/.claude/skills/moai-foundation-tags/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-foundation-tags/reference.md +28 -0
- moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +253 -32
- moai_adk/templates/.claude/skills/moai-foundation-trust/examples.md +0 -0
- moai_adk/templates/.claude/skills/moai-foundation-trust/reference.md +1099 -0
- moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-lang-c/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-c/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +98 -76
- moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +97 -74
- moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +86 -61
- moai_adk/templates/.claude/skills/moai-lang-dart/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-dart/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-lang-go/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-go/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +87 -61
- moai_adk/templates/.claude/skills/moai-lang-java/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-java/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +88 -59
- moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +32 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +98 -73
- moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +86 -61
- moai_adk/templates/.claude/skills/moai-lang-php/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-php/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +388 -53
- moai_adk/templates/.claude/skills/moai-lang-python/examples.md +624 -0
- moai_adk/templates/.claude/skills/moai-lang-python/reference.md +316 -0
- moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +97 -73
- moai_adk/templates/.claude/skills/moai-lang-r/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-r/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +98 -73
- moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +97 -74
- moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +97 -74
- moai_adk/templates/.claude/skills/moai-lang-shell/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-shell/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +98 -74
- moai_adk/templates/.claude/skills/moai-lang-sql/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-sql/reference.md +31 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +97 -73
- moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +30 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +90 -59
- moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +29 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +34 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/CHECKLIST.md +482 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/EXAMPLES.md +278 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/INTERACTIVE-DISCOVERY.md +524 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/METADATA.md +477 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/PARALLEL-ANALYSIS-REPORT.md +429 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/PYTHON-VERSION-MATRIX.md +391 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL-FACTORY-WORKFLOW.md +431 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL-UPDATE-ADVISOR.md +577 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL.md +560 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/STEP-BY-STEP-GUIDE.md +466 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/STRUCTURE.md +583 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/WEB-RESEARCH.md +526 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/reference.md +465 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/scripts/generate-structure.sh +328 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/scripts/validate-skill.sh +312 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/SKILL_TEMPLATE.md +245 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/examples-template.md +285 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/reference-template.md +278 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/scripts-template.sh +303 -0
- moai_adk/templates/.claude/skills/moai-spec-authoring/README.md +129 -0
- moai_adk/templates/.claude/skills/moai-spec-authoring/SKILL.md +1300 -0
- moai_adk/templates/.claude/skills/moai-spec-authoring/examples/validate-spec.sh +161 -0
- moai_adk/templates/CLAUDE.md +121 -81
- moai_adk-0.4.8.dist-info/METADATA +1553 -0
- moai_adk-0.4.8.dist-info/RECORD +265 -0
- moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/SKILL.md +0 -112
- moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/SKILL.md +0 -103
- moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/SKILL.md +0 -105
- moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/SKILL.md +0 -97
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/SKILL.md +0 -87
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/examples.md +0 -62
- moai_adk/templates/.claude/skills/moai-claude-code/SKILL.md +0 -94
- moai_adk/templates/.claude/skills/moai-claude-code/examples.md +0 -513
- moai_adk/templates/.claude/skills/moai-claude-code/reference.md +0 -433
- moai_adk/templates/.claude/skills/moai-claude-code/templates/agent-full.md +0 -332
- moai_adk/templates/.claude/skills/moai-claude-code/templates/command-full.md +0 -384
- moai_adk/templates/.claude/skills/moai-claude-code/templates/plugin-full.json +0 -363
- moai_adk/templates/.claude/skills/moai-claude-code/templates/settings-full.json +0 -595
- moai_adk/templates/.claude/skills/moai-claude-code/templates/skill-full.md +0 -496
- moai_adk/templates/.claude/skills/moai-lang-clojure/SKILL.md +0 -100
- moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +0 -99
- moai_adk/templates/.claude/skills/moai-lang-haskell/SKILL.md +0 -100
- moai_adk/templates/.claude/skills/moai-lang-julia/SKILL.md +0 -98
- moai_adk/templates/.claude/skills/moai-lang-lua/SKILL.md +0 -98
- moai_adk-0.4.5.dist-info/METADATA +0 -369
- moai_adk-0.4.5.dist-info/RECORD +0 -152
- {moai_adk-0.4.5.dist-info → moai_adk-0.4.8.dist-info}/WHEEL +0 -0
- {moai_adk-0.4.5.dist-info → moai_adk-0.4.8.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.4.5.dist-info → moai_adk-0.4.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,1300 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: moai-spec-authoring
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
created: 2025-10-23
|
|
5
|
+
updated: 2025-10-23
|
|
6
|
+
status: active
|
|
7
|
+
description: Comprehensive guide for authoring MoAI-ADK SPEC documents with proper metadata, EARS syntax, and best practices.
|
|
8
|
+
keywords: ['spec', 'authoring', 'ears', 'metadata', 'requirements', 'tdd', 'planning']
|
|
9
|
+
allowed-tools:
|
|
10
|
+
- Read
|
|
11
|
+
- Bash
|
|
12
|
+
- Glob
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# SPEC Authoring Skill
|
|
16
|
+
|
|
17
|
+
## Skill Metadata
|
|
18
|
+
|
|
19
|
+
| Field | Value |
|
|
20
|
+
| ----- | ----- |
|
|
21
|
+
| **Skill Name** | moai-spec-authoring |
|
|
22
|
+
| **Version** | 1.0.0 (2025-10-23) |
|
|
23
|
+
| **Allowed tools** | Read, Bash, Glob |
|
|
24
|
+
| **Auto-load** | `/alfred:1-plan`, SPEC writing tasks |
|
|
25
|
+
| **Tier** | Foundation |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## What It Does
|
|
30
|
+
|
|
31
|
+
Comprehensive guide for authoring high-quality MoAI-ADK SPEC documents. Covers YAML metadata structure (7 required + 9 optional fields), EARS requirement syntax (5 patterns), versioning lifecycle, TAG integration, and validation strategies.
|
|
32
|
+
|
|
33
|
+
**Key capabilities**:
|
|
34
|
+
- Step-by-step SPEC creation workflow
|
|
35
|
+
- Complete metadata field reference with examples
|
|
36
|
+
- EARS syntax templates with real-world patterns
|
|
37
|
+
- Pre-submission validation checklist
|
|
38
|
+
- Common pitfalls prevention
|
|
39
|
+
- Integration with `/alfred:1-plan` workflow
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## When to Use
|
|
44
|
+
|
|
45
|
+
**Automatic triggers**:
|
|
46
|
+
- `/alfred:1-plan` command execution
|
|
47
|
+
- SPEC document creation requests
|
|
48
|
+
- Requirement clarification discussions
|
|
49
|
+
- Feature planning sessions
|
|
50
|
+
|
|
51
|
+
**Manual invocation**:
|
|
52
|
+
- Learning SPEC authoring best practices
|
|
53
|
+
- Validating existing SPEC documents
|
|
54
|
+
- Troubleshooting metadata issues
|
|
55
|
+
- Understanding EARS syntax patterns
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Quick Start: 5-Step SPEC Creation
|
|
60
|
+
|
|
61
|
+
### Step 1: Initialize SPEC Directory
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Create SPEC directory structure
|
|
65
|
+
mkdir -p .moai/specs/SPEC-{DOMAIN}-{NUMBER}
|
|
66
|
+
cd .moai/specs/SPEC-{DOMAIN}-{NUMBER}
|
|
67
|
+
|
|
68
|
+
# Example: Authentication feature
|
|
69
|
+
mkdir -p .moai/specs/SPEC-AUTH-001
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Step 2: Create `spec.md` with YAML Front Matter
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
---
|
|
76
|
+
# Required Fields (7)
|
|
77
|
+
id: AUTH-001
|
|
78
|
+
version: 0.0.1
|
|
79
|
+
status: draft
|
|
80
|
+
created: 2025-10-23
|
|
81
|
+
updated: 2025-10-23
|
|
82
|
+
author: @YourGitHubHandle
|
|
83
|
+
priority: high
|
|
84
|
+
|
|
85
|
+
# Optional Fields (recommended)
|
|
86
|
+
category: feature
|
|
87
|
+
labels:
|
|
88
|
+
- authentication
|
|
89
|
+
- security
|
|
90
|
+
- jwt
|
|
91
|
+
---
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Step 3: Add SPEC Title & HISTORY
|
|
95
|
+
|
|
96
|
+
```markdown
|
|
97
|
+
# @SPEC:AUTH-001: JWT Authentication System
|
|
98
|
+
|
|
99
|
+
## HISTORY
|
|
100
|
+
|
|
101
|
+
### v0.0.1 (2025-10-23)
|
|
102
|
+
- **INITIAL**: JWT-based authentication SPEC draft created
|
|
103
|
+
- **AUTHOR**: @YourGitHubHandle
|
|
104
|
+
- **SCOPE**: User authentication, token generation, token validation
|
|
105
|
+
- **CONTEXT**: Requirement from product roadmap
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Step 4: Define Environment & Assumptions
|
|
109
|
+
|
|
110
|
+
```markdown
|
|
111
|
+
## Environment
|
|
112
|
+
|
|
113
|
+
**Execution Context**:
|
|
114
|
+
- Runtime: Node.js 20.x or later
|
|
115
|
+
- Framework: Express.js
|
|
116
|
+
- Database: PostgreSQL 15+
|
|
117
|
+
|
|
118
|
+
**Technical Stack**:
|
|
119
|
+
- JWT library: jsonwebtoken ^9.0.0
|
|
120
|
+
- Hashing: bcrypt ^5.1.0
|
|
121
|
+
|
|
122
|
+
**Constraints**:
|
|
123
|
+
- Token lifetime: 15 minutes (access), 7 days (refresh)
|
|
124
|
+
- Security: HTTPS required in production
|
|
125
|
+
|
|
126
|
+
## Assumptions
|
|
127
|
+
|
|
128
|
+
1. **User Storage**: User credentials stored in PostgreSQL
|
|
129
|
+
2. **Secret Management**: JWT secrets managed via environment variables
|
|
130
|
+
3. **Clock Sync**: Server clocks synchronized (NTP)
|
|
131
|
+
4. **Password Policy**: Minimum 8 characters enforced at signup
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Step 5: Write EARS Requirements
|
|
135
|
+
|
|
136
|
+
```markdown
|
|
137
|
+
## Requirements
|
|
138
|
+
|
|
139
|
+
### Ubiquitous Requirements
|
|
140
|
+
|
|
141
|
+
**UR-001**: The system shall provide JWT-based authentication.
|
|
142
|
+
|
|
143
|
+
**UR-002**: The system shall support user login with email and password.
|
|
144
|
+
|
|
145
|
+
**UR-003**: The system shall issue access tokens and refresh tokens.
|
|
146
|
+
|
|
147
|
+
### Event-driven Requirements
|
|
148
|
+
|
|
149
|
+
**ER-001**: WHEN a user submits valid credentials, the system shall issue a JWT access token with 15-minute expiry.
|
|
150
|
+
|
|
151
|
+
**ER-002**: WHEN a token expires, the system shall return HTTP 401 Unauthorized.
|
|
152
|
+
|
|
153
|
+
**ER-003**: WHEN a refresh token is presented, the system shall issue a new access token IF the refresh token is valid.
|
|
154
|
+
|
|
155
|
+
### State-driven Requirements
|
|
156
|
+
|
|
157
|
+
**SR-001**: WHILE a user is authenticated, the system shall allow access to protected resources.
|
|
158
|
+
|
|
159
|
+
**SR-002**: WHILE a token is valid, the system shall extract user ID from token claims.
|
|
160
|
+
|
|
161
|
+
### Optional Features
|
|
162
|
+
|
|
163
|
+
**OF-001**: WHERE multi-factor authentication is enabled, the system can require OTP verification after password check.
|
|
164
|
+
|
|
165
|
+
**OF-002**: WHERE session logging is enabled, the system can record login timestamps and IP addresses.
|
|
166
|
+
|
|
167
|
+
### Constraints
|
|
168
|
+
|
|
169
|
+
**C-001**: IF a token is expired, the system shall deny access and return HTTP 401.
|
|
170
|
+
|
|
171
|
+
**C-002**: IF more than 5 failed login attempts occur within 10 minutes, the system should temporarily lock the account.
|
|
172
|
+
|
|
173
|
+
**C-003**: Access tokens shall not exceed 15-minute lifetime.
|
|
174
|
+
|
|
175
|
+
**C-004**: Refresh tokens shall not exceed 7-day lifetime.
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Metadata Reference
|
|
181
|
+
|
|
182
|
+
### 7 Required Fields
|
|
183
|
+
|
|
184
|
+
#### 1. `id` – Unique SPEC Identifier
|
|
185
|
+
|
|
186
|
+
**Format**: `<DOMAIN>-<NUMBER>`
|
|
187
|
+
|
|
188
|
+
**Rules**:
|
|
189
|
+
- Immutable once assigned
|
|
190
|
+
- Use uppercase domain (e.g., `AUTH`, `PAYMENT`, `CONFIG`)
|
|
191
|
+
- Three-digit number (001–999)
|
|
192
|
+
- Check duplicates: `rg "@SPEC:AUTH-001" -n .moai/specs/`
|
|
193
|
+
|
|
194
|
+
**Examples**:
|
|
195
|
+
- `AUTH-001` (Authentication feature)
|
|
196
|
+
- `INSTALLER-SEC-001` (Installer security)
|
|
197
|
+
- `TRUST-001` (TRUST principles)
|
|
198
|
+
- `CONFIG-001` (Configuration schema)
|
|
199
|
+
|
|
200
|
+
**Directory Structure**:
|
|
201
|
+
```
|
|
202
|
+
.moai/specs/SPEC-AUTH-001/
|
|
203
|
+
├── spec.md # Main SPEC document
|
|
204
|
+
├── diagrams/ # Optional: Architecture diagrams
|
|
205
|
+
└── examples/ # Optional: Code examples
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### 2. `version` – Semantic Version
|
|
209
|
+
|
|
210
|
+
**Format**: `MAJOR.MINOR.PATCH`
|
|
211
|
+
|
|
212
|
+
**Lifecycle**:
|
|
213
|
+
|
|
214
|
+
| Version | Status | Description | Trigger |
|
|
215
|
+
|---------|--------|-------------|---------|
|
|
216
|
+
| `0.0.1` | draft | Initial draft | SPEC creation |
|
|
217
|
+
| `0.0.x` | draft | Draft refinements | Content edits |
|
|
218
|
+
| `0.1.0` | completed | Implementation complete | `/alfred:3-sync` after TDD |
|
|
219
|
+
| `0.1.x` | completed | Bug fixes, doc updates | Post-implementation patches |
|
|
220
|
+
| `0.x.0` | completed | Feature additions | Minor enhancements |
|
|
221
|
+
| `1.0.0` | completed | Production stable | Stakeholder approval |
|
|
222
|
+
|
|
223
|
+
**Version Update Examples**:
|
|
224
|
+
```markdown
|
|
225
|
+
## HISTORY
|
|
226
|
+
|
|
227
|
+
### v0.2.0 (2025-11-15)
|
|
228
|
+
- **ADDED**: Multi-factor authentication support
|
|
229
|
+
- **CHANGED**: Token expiry extended to 30 minutes
|
|
230
|
+
- **AUTHOR**: @YourHandle
|
|
231
|
+
|
|
232
|
+
### v0.1.0 (2025-10-30)
|
|
233
|
+
- **COMPLETED**: TDD implementation finished
|
|
234
|
+
- **EVIDENCE**: Commits 4c66076, 34e1bd9
|
|
235
|
+
- **TEST COVERAGE**: 89.13%
|
|
236
|
+
|
|
237
|
+
### v0.0.2 (2025-10-25)
|
|
238
|
+
- **REFINED**: Added password reset flow requirements
|
|
239
|
+
- **AUTHOR**: @YourHandle
|
|
240
|
+
|
|
241
|
+
### v0.0.1 (2025-10-23)
|
|
242
|
+
- **INITIAL**: JWT authentication SPEC draft created
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### 3. `status` – Progress State
|
|
246
|
+
|
|
247
|
+
**Values**: `draft` | `active` | `completed` | `deprecated`
|
|
248
|
+
|
|
249
|
+
**Lifecycle Flow**:
|
|
250
|
+
```
|
|
251
|
+
draft → active → completed → [deprecated]
|
|
252
|
+
↓ ↓ ↓
|
|
253
|
+
/alfred:1-plan /alfred:2-run /alfred:3-sync
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**Transitions**:
|
|
257
|
+
- `draft`: Authoring in progress (v0.0.x)
|
|
258
|
+
- `active`: Implementation underway (v0.0.x → v0.1.0)
|
|
259
|
+
- `completed`: Implementation finished (v0.1.0+)
|
|
260
|
+
- `deprecated`: Marked for retirement
|
|
261
|
+
|
|
262
|
+
#### 4. `created` – Creation Date
|
|
263
|
+
|
|
264
|
+
**Format**: `YYYY-MM-DD`
|
|
265
|
+
|
|
266
|
+
**Rules**:
|
|
267
|
+
- Set once, never changes
|
|
268
|
+
- ISO 8601 date format
|
|
269
|
+
- Represents first draft date
|
|
270
|
+
|
|
271
|
+
**Example**: `created: 2025-10-23`
|
|
272
|
+
|
|
273
|
+
#### 5. `updated` – Last Modified Date
|
|
274
|
+
|
|
275
|
+
**Format**: `YYYY-MM-DD`
|
|
276
|
+
|
|
277
|
+
**Rules**:
|
|
278
|
+
- Update on every content change
|
|
279
|
+
- Initially same as `created`
|
|
280
|
+
- Reflects latest edit date
|
|
281
|
+
|
|
282
|
+
**Update Pattern**:
|
|
283
|
+
```yaml
|
|
284
|
+
created: 2025-10-23 # Never changes
|
|
285
|
+
updated: 2025-10-25 # Changes with edits
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
#### 6. `author` – Primary Author
|
|
289
|
+
|
|
290
|
+
**Format**: `@{GitHubHandle}`
|
|
291
|
+
|
|
292
|
+
**Rules**:
|
|
293
|
+
- Single value (not array)
|
|
294
|
+
- Prefix with `@`
|
|
295
|
+
- Use proper casing (e.g., `@Goos`, not `@goos`)
|
|
296
|
+
- Additional contributors go in HISTORY section
|
|
297
|
+
|
|
298
|
+
**Examples**:
|
|
299
|
+
```yaml
|
|
300
|
+
# Correct
|
|
301
|
+
author: @Goos
|
|
302
|
+
|
|
303
|
+
# Incorrect
|
|
304
|
+
author: goos # Missing @
|
|
305
|
+
authors: [@Goos] # Array not allowed
|
|
306
|
+
author: @goos # Wrong casing
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
#### 7. `priority` – Work Priority
|
|
310
|
+
|
|
311
|
+
**Values**: `critical` | `high` | `medium` | `low`
|
|
312
|
+
|
|
313
|
+
**Guidelines**:
|
|
314
|
+
|
|
315
|
+
| Priority | Description | Examples |
|
|
316
|
+
|----------|-------------|----------|
|
|
317
|
+
| `critical` | Production blockers, security vulnerabilities | Security patches, critical bugs |
|
|
318
|
+
| `high` | Major features, core functionality | Authentication, payment system |
|
|
319
|
+
| `medium` | Enhancements, improvements | UI polish, performance optimization |
|
|
320
|
+
| `low` | Nice-to-haves, documentation | README updates, minor refactors |
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
### 9 Optional Fields
|
|
325
|
+
|
|
326
|
+
#### 8. `category` – Change Type
|
|
327
|
+
|
|
328
|
+
**Values**: `feature` | `bugfix` | `refactor` | `security` | `docs` | `perf`
|
|
329
|
+
|
|
330
|
+
**Usage**:
|
|
331
|
+
```yaml
|
|
332
|
+
category: feature # New functionality
|
|
333
|
+
category: bugfix # Defect resolution
|
|
334
|
+
category: refactor # Code structure improvement
|
|
335
|
+
category: security # Security enhancement
|
|
336
|
+
category: docs # Documentation update
|
|
337
|
+
category: perf # Performance optimization
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
#### 9. `labels` – Classification Tags
|
|
341
|
+
|
|
342
|
+
**Format**: Array of strings
|
|
343
|
+
|
|
344
|
+
**Purpose**: Search, filtering, grouping
|
|
345
|
+
|
|
346
|
+
**Best Practices**:
|
|
347
|
+
- Use lowercase, kebab-case
|
|
348
|
+
- 2-5 labels per SPEC
|
|
349
|
+
- Avoid redundancy with `category`
|
|
350
|
+
|
|
351
|
+
**Examples**:
|
|
352
|
+
```yaml
|
|
353
|
+
labels:
|
|
354
|
+
- authentication
|
|
355
|
+
- jwt
|
|
356
|
+
- security
|
|
357
|
+
|
|
358
|
+
labels:
|
|
359
|
+
- performance
|
|
360
|
+
- optimization
|
|
361
|
+
- caching
|
|
362
|
+
|
|
363
|
+
labels:
|
|
364
|
+
- installer
|
|
365
|
+
- template
|
|
366
|
+
- cross-platform
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
#### 10-13. Relationship Fields (Dependency Graph)
|
|
370
|
+
|
|
371
|
+
##### `depends_on` – Required SPECs
|
|
372
|
+
|
|
373
|
+
**Meaning**: SPECs that must be completed first
|
|
374
|
+
|
|
375
|
+
**Example**:
|
|
376
|
+
```yaml
|
|
377
|
+
depends_on:
|
|
378
|
+
- USER-001 # User model SPEC
|
|
379
|
+
- TOKEN-001 # Token generation SPEC
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**Use Case**: Determines execution order, parallelization
|
|
383
|
+
|
|
384
|
+
##### `blocks` – Blocked SPECs
|
|
385
|
+
|
|
386
|
+
**Meaning**: SPECs that cannot proceed until this one is resolved
|
|
387
|
+
|
|
388
|
+
**Example**:
|
|
389
|
+
```yaml
|
|
390
|
+
blocks:
|
|
391
|
+
- AUTH-002 # OAuth integration waits for basic auth
|
|
392
|
+
- PAYMENT-001 # Payment needs authentication
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
##### `related_specs` – Associated SPECs
|
|
396
|
+
|
|
397
|
+
**Meaning**: Related items without direct dependencies
|
|
398
|
+
|
|
399
|
+
**Example**:
|
|
400
|
+
```yaml
|
|
401
|
+
related_specs:
|
|
402
|
+
- SESSION-001 # Session management (related but independent)
|
|
403
|
+
- AUDIT-001 # Audit logging (cross-cutting concern)
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
##### `related_issue` – Linked GitHub Issue
|
|
407
|
+
|
|
408
|
+
**Format**: Full GitHub issue URL
|
|
409
|
+
|
|
410
|
+
**Example**:
|
|
411
|
+
```yaml
|
|
412
|
+
related_issue: "https://github.com/modu-ai/moai-adk/issues/42"
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
#### 14-15. Scope Fields (Impact Analysis)
|
|
416
|
+
|
|
417
|
+
##### `scope.packages` – Impacted Packages
|
|
418
|
+
|
|
419
|
+
**Purpose**: Track which packages/modules are affected
|
|
420
|
+
|
|
421
|
+
**Example**:
|
|
422
|
+
```yaml
|
|
423
|
+
scope:
|
|
424
|
+
packages:
|
|
425
|
+
- src/core/auth
|
|
426
|
+
- src/core/token
|
|
427
|
+
- src/api/routes/auth
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
##### `scope.files` – Key Files
|
|
431
|
+
|
|
432
|
+
**Purpose**: Reference primary implementation files
|
|
433
|
+
|
|
434
|
+
**Example**:
|
|
435
|
+
```yaml
|
|
436
|
+
scope:
|
|
437
|
+
files:
|
|
438
|
+
- auth-service.ts
|
|
439
|
+
- token-manager.ts
|
|
440
|
+
- auth.routes.ts
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## EARS Requirement Syntax
|
|
446
|
+
|
|
447
|
+
### The 5 EARS Patterns
|
|
448
|
+
|
|
449
|
+
EARS (Easy Approach to Requirements Syntax) provides disciplined, testable requirements using familiar keywords.
|
|
450
|
+
|
|
451
|
+
#### Pattern 1: Ubiquitous Requirements
|
|
452
|
+
|
|
453
|
+
**Template**: `The system shall [capability].`
|
|
454
|
+
|
|
455
|
+
**Purpose**: Baseline functionality always active
|
|
456
|
+
|
|
457
|
+
**Characteristics**:
|
|
458
|
+
- No preconditions
|
|
459
|
+
- Always applicable
|
|
460
|
+
- Defines core features
|
|
461
|
+
|
|
462
|
+
**Examples**:
|
|
463
|
+
```markdown
|
|
464
|
+
**UR-001**: The system shall provide user authentication.
|
|
465
|
+
|
|
466
|
+
**UR-002**: The system shall support HTTPS connections.
|
|
467
|
+
|
|
468
|
+
**UR-003**: The system shall store user credentials securely.
|
|
469
|
+
|
|
470
|
+
**UR-004**: The mobile app shall have a mass of less than 50 MB.
|
|
471
|
+
|
|
472
|
+
**UR-005**: The API response time shall not exceed 200ms for 95% of requests.
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
**Best Practices**:
|
|
476
|
+
- ✅ Use active voice
|
|
477
|
+
- ✅ Single responsibility per requirement
|
|
478
|
+
- ✅ Measurable outcomes
|
|
479
|
+
- ❌ Avoid vague terms ("user-friendly", "fast")
|
|
480
|
+
|
|
481
|
+
#### Pattern 2: Event-driven Requirements
|
|
482
|
+
|
|
483
|
+
**Template**: `WHEN [trigger], the system shall [response].`
|
|
484
|
+
|
|
485
|
+
**Purpose**: Define behavior triggered by specific events
|
|
486
|
+
|
|
487
|
+
**Characteristics**:
|
|
488
|
+
- Triggered by discrete events
|
|
489
|
+
- One-time response
|
|
490
|
+
- Cause-and-effect relationship
|
|
491
|
+
|
|
492
|
+
**Examples**:
|
|
493
|
+
```markdown
|
|
494
|
+
**ER-001**: WHEN a user submits valid credentials, the system shall issue a JWT token.
|
|
495
|
+
|
|
496
|
+
**ER-002**: WHEN a token expires, the system shall return HTTP 401 Unauthorized.
|
|
497
|
+
|
|
498
|
+
**ER-003**: WHEN a user clicks "Forgot Password", the system shall send a password reset email.
|
|
499
|
+
|
|
500
|
+
**ER-004**: WHEN the database connection fails, the system shall retry 3 times with exponential backoff.
|
|
501
|
+
|
|
502
|
+
**ER-005**: WHEN a file upload exceeds 10 MB, the system shall reject the upload with error message.
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
**Advanced Pattern** (with postcondition):
|
|
506
|
+
```markdown
|
|
507
|
+
**ER-006**: WHEN a payment transaction completes, the system shall send a confirmation email THEN update the order status to "paid".
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
**Best Practices**:
|
|
511
|
+
- ✅ Single trigger per requirement
|
|
512
|
+
- ✅ Specific, testable response
|
|
513
|
+
- ✅ Include error conditions
|
|
514
|
+
- ❌ Don't chain multiple WHENs
|
|
515
|
+
|
|
516
|
+
#### Pattern 3: State-driven Requirements
|
|
517
|
+
|
|
518
|
+
**Template**: `WHILE [state], the system shall [behavior].`
|
|
519
|
+
|
|
520
|
+
**Purpose**: Continuous behavior during a state
|
|
521
|
+
|
|
522
|
+
**Characteristics**:
|
|
523
|
+
- Active while state persists
|
|
524
|
+
- Continuous monitoring
|
|
525
|
+
- State-dependent behavior
|
|
526
|
+
|
|
527
|
+
**Examples**:
|
|
528
|
+
```markdown
|
|
529
|
+
**SR-001**: WHILE a user is authenticated, the system shall allow access to protected routes.
|
|
530
|
+
|
|
531
|
+
**SR-002**: WHILE a token is valid, the system shall extract user ID from token claims.
|
|
532
|
+
|
|
533
|
+
**SR-003**: WHILE the system is in maintenance mode, the system shall return HTTP 503 Service Unavailable.
|
|
534
|
+
|
|
535
|
+
**SR-004**: WHILE battery level is below 20%, the mobile app shall reduce background sync frequency.
|
|
536
|
+
|
|
537
|
+
**SR-005**: WHILE a file upload is in progress, the UI shall display a progress bar.
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
**Best Practices**:
|
|
541
|
+
- ✅ Clearly define state boundaries
|
|
542
|
+
- ✅ Specify state entry/exit conditions
|
|
543
|
+
- ✅ Test state transitions
|
|
544
|
+
- ❌ Avoid overlapping states
|
|
545
|
+
|
|
546
|
+
#### Pattern 4: Optional Features
|
|
547
|
+
|
|
548
|
+
**Template**: `WHERE [feature], the system can [behavior].`
|
|
549
|
+
|
|
550
|
+
**Purpose**: Conditional functionality based on feature flags
|
|
551
|
+
|
|
552
|
+
**Characteristics**:
|
|
553
|
+
- Applies only if feature is present
|
|
554
|
+
- Configuration-dependent
|
|
555
|
+
- Product variation support
|
|
556
|
+
|
|
557
|
+
**Examples**:
|
|
558
|
+
```markdown
|
|
559
|
+
**OF-001**: WHERE multi-factor authentication is enabled, the system can require OTP verification.
|
|
560
|
+
|
|
561
|
+
**OF-002**: WHERE session logging is enabled, the system can record login timestamps.
|
|
562
|
+
|
|
563
|
+
**OF-003**: WHERE premium subscription is active, the system can allow unlimited API calls.
|
|
564
|
+
|
|
565
|
+
**OF-004**: WHERE dark mode is selected, the UI can render with dark color scheme.
|
|
566
|
+
|
|
567
|
+
**OF-005**: WHERE analytics consent is granted, the system can track user behavior.
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
**Best Practices**:
|
|
571
|
+
- ✅ Use "can" (permissive) not "shall" (mandatory)
|
|
572
|
+
- ✅ Clearly define feature flag conditions
|
|
573
|
+
- ✅ Specify default behavior when feature is absent
|
|
574
|
+
- ❌ Don't make core features optional
|
|
575
|
+
|
|
576
|
+
#### Pattern 5: Constraints
|
|
577
|
+
|
|
578
|
+
**Template**: `IF [condition], THEN the system shall [constraint].`
|
|
579
|
+
|
|
580
|
+
**Purpose**: Enforce quality attributes and business rules
|
|
581
|
+
|
|
582
|
+
**Characteristics**:
|
|
583
|
+
- Conditional enforcement
|
|
584
|
+
- Quality gates
|
|
585
|
+
- Business rule validation
|
|
586
|
+
|
|
587
|
+
**Examples**:
|
|
588
|
+
```markdown
|
|
589
|
+
**C-001**: IF a token is expired, THEN the system shall deny access and return HTTP 401.
|
|
590
|
+
|
|
591
|
+
**C-002**: IF more than 5 failed login attempts occur within 10 minutes, THEN the system should temporarily lock the account.
|
|
592
|
+
|
|
593
|
+
**C-003**: Access tokens shall not exceed 15-minute lifetime.
|
|
594
|
+
|
|
595
|
+
**C-004**: IF a password is less than 8 characters, THEN the system shall reject registration.
|
|
596
|
+
|
|
597
|
+
**C-005**: IF API rate limit is exceeded, THEN the system shall return HTTP 429 Too Many Requests.
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
**Simplified Constraint** (no condition):
|
|
601
|
+
```markdown
|
|
602
|
+
**C-006**: The system shall not store plaintext passwords.
|
|
603
|
+
|
|
604
|
+
**C-007**: All API endpoints shall require authentication except /health and /login.
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
**Best Practices**:
|
|
608
|
+
- ✅ Use SHALL for hard constraints, SHOULD for soft recommendations
|
|
609
|
+
- ✅ Quantify limits (time, size, count)
|
|
610
|
+
- ✅ Specify enforcement mechanism
|
|
611
|
+
- ❌ Avoid vague constraints
|
|
612
|
+
|
|
613
|
+
---
|
|
614
|
+
|
|
615
|
+
### EARS Pattern Selection Guide
|
|
616
|
+
|
|
617
|
+
| Pattern | Keyword | Use When | Example Context |
|
|
618
|
+
|---------|---------|----------|-----------------|
|
|
619
|
+
| **Ubiquitous** | shall | Core functionality, always active | "System shall provide login" |
|
|
620
|
+
| **Event-driven** | WHEN | Response to discrete event | "WHEN login fails, show error" |
|
|
621
|
+
| **State-driven** | WHILE | Continuous behavior in state | "WHILE logged in, allow access" |
|
|
622
|
+
| **Optional** | WHERE | Feature flag or configuration | "WHERE premium, unlock features" |
|
|
623
|
+
| **Constraints** | IF-THEN | Quality gates, business rules | "IF expired, deny access" |
|
|
624
|
+
|
|
625
|
+
---
|
|
626
|
+
|
|
627
|
+
### Real-World EARS Examples
|
|
628
|
+
|
|
629
|
+
#### Example 1: E-commerce Checkout
|
|
630
|
+
|
|
631
|
+
```markdown
|
|
632
|
+
### Ubiquitous Requirements
|
|
633
|
+
**UR-001**: The system shall provide a shopping cart.
|
|
634
|
+
**UR-002**: The system shall support credit card payments.
|
|
635
|
+
|
|
636
|
+
### Event-driven Requirements
|
|
637
|
+
**ER-001**: WHEN a user adds an item to cart, the system shall update the cart total.
|
|
638
|
+
**ER-002**: WHEN payment is successful, the system shall send order confirmation email.
|
|
639
|
+
**ER-003**: WHEN inventory is insufficient, the system shall display "out of stock" message.
|
|
640
|
+
|
|
641
|
+
### State-driven Requirements
|
|
642
|
+
**SR-001**: WHILE items are in cart, the system shall reserve inventory for 30 minutes.
|
|
643
|
+
**SR-002**: WHILE payment is processing, the UI shall display a loading indicator.
|
|
644
|
+
|
|
645
|
+
### Optional Features
|
|
646
|
+
**OF-001**: WHERE express shipping is selected, the system can calculate expedited shipping cost.
|
|
647
|
+
**OF-002**: WHERE gift wrapping is available, the system can offer gift wrap option.
|
|
648
|
+
|
|
649
|
+
### Constraints
|
|
650
|
+
**C-001**: IF cart total is below $50, THEN the system shall add $5 shipping fee.
|
|
651
|
+
**C-002**: IF payment fails after 3 attempts, THEN the system shall lock the order for 1 hour.
|
|
652
|
+
**C-003**: Order processing time shall not exceed 5 seconds.
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
#### Example 2: Mobile App Push Notifications
|
|
656
|
+
|
|
657
|
+
```markdown
|
|
658
|
+
### Ubiquitous Requirements
|
|
659
|
+
**UR-001**: The app shall support push notifications.
|
|
660
|
+
**UR-002**: The app shall allow users to enable/disable notifications.
|
|
661
|
+
|
|
662
|
+
### Event-driven Requirements
|
|
663
|
+
**ER-001**: WHEN a new message arrives, the app shall display a push notification.
|
|
664
|
+
**ER-002**: WHEN a notification is tapped, the app shall navigate to the message screen.
|
|
665
|
+
**ER-003**: WHEN notification permission is denied, the app shall show in-app notification banner.
|
|
666
|
+
|
|
667
|
+
### State-driven Requirements
|
|
668
|
+
**SR-001**: WHILE the app is in foreground, the system shall display in-app banners instead of push notifications.
|
|
669
|
+
**SR-002**: WHILE Do Not Disturb mode is active, the system shall silence all notifications.
|
|
670
|
+
|
|
671
|
+
### Optional Features
|
|
672
|
+
**OF-001**: WHERE notification sounds are enabled, the system can play notification sound.
|
|
673
|
+
**OF-002**: WHERE notification grouping is supported, the system can group notifications by conversation.
|
|
674
|
+
|
|
675
|
+
### Constraints
|
|
676
|
+
**C-001**: IF more than 10 notifications are pending, THEN the system shall group them into a summary notification.
|
|
677
|
+
**C-002**: Notification delivery latency shall not exceed 5 seconds.
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
---
|
|
681
|
+
|
|
682
|
+
## HISTORY Section Format
|
|
683
|
+
|
|
684
|
+
The HISTORY section documents all SPEC versions and their changes.
|
|
685
|
+
|
|
686
|
+
### Structure
|
|
687
|
+
|
|
688
|
+
```markdown
|
|
689
|
+
## HISTORY
|
|
690
|
+
|
|
691
|
+
### v{MAJOR}.{MINOR}.{PATCH} ({YYYY-MM-DD})
|
|
692
|
+
- **{CHANGE_TYPE}**: {Description}
|
|
693
|
+
- **AUTHOR**: {GitHub handle}
|
|
694
|
+
- **{Additional context}**: {Details}
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
### Change Types
|
|
698
|
+
|
|
699
|
+
| Type | Description | Example |
|
|
700
|
+
|------|-------------|---------|
|
|
701
|
+
| **INITIAL** | First draft | `v0.0.1: INITIAL draft created` |
|
|
702
|
+
| **REFINED** | Content updates during draft | `v0.0.2: REFINED requirements based on review` |
|
|
703
|
+
| **COMPLETED** | Implementation finished | `v0.1.0: COMPLETED TDD implementation` |
|
|
704
|
+
| **ADDED** | New requirements/features | `v0.2.0: ADDED multi-factor authentication` |
|
|
705
|
+
| **CHANGED** | Modified requirements | `v0.2.0: CHANGED token expiry from 15min to 30min` |
|
|
706
|
+
| **FIXED** | Bug fixes post-implementation | `v0.1.1: FIXED token refresh logic` |
|
|
707
|
+
| **DEPRECATED** | Marked for retirement | `v1.5.0: DEPRECATED legacy auth endpoint` |
|
|
708
|
+
|
|
709
|
+
### Complete HISTORY Example
|
|
710
|
+
|
|
711
|
+
```markdown
|
|
712
|
+
## HISTORY
|
|
713
|
+
|
|
714
|
+
### v0.2.0 (2025-11-15)
|
|
715
|
+
- **ADDED**: Multi-factor authentication support via OTP
|
|
716
|
+
- **CHANGED**: Token expiry extended to 30 minutes based on user feedback
|
|
717
|
+
- **AUTHOR**: @Goos
|
|
718
|
+
- **REVIEWER**: @SecurityTeam
|
|
719
|
+
- **RATIONALE**: Improved UX while maintaining security posture
|
|
720
|
+
|
|
721
|
+
### v0.1.1 (2025-11-01)
|
|
722
|
+
- **FIXED**: Token refresh race condition
|
|
723
|
+
- **EVIDENCE**: Commit 3f9a2b7
|
|
724
|
+
- **AUTHOR**: @Goos
|
|
725
|
+
|
|
726
|
+
### v0.1.0 (2025-10-30)
|
|
727
|
+
- **COMPLETED**: TDD implementation finished
|
|
728
|
+
- **AUTHOR**: @Goos
|
|
729
|
+
- **EVIDENCE**: Commits 4c66076, 34e1bd9, 1dec08f
|
|
730
|
+
- **TEST COVERAGE**: 89.13% (target: 85%)
|
|
731
|
+
- **QUALITY METRICS**:
|
|
732
|
+
- Test Pass Rate: 100% (42/42 tests)
|
|
733
|
+
- Linting: ruff ✅
|
|
734
|
+
- Type Checking: mypy ✅
|
|
735
|
+
- **TAG CHAIN**:
|
|
736
|
+
- @SPEC:AUTH-001: 1 occurrence
|
|
737
|
+
- @TEST:AUTH-001: 8 occurrences
|
|
738
|
+
- @CODE:AUTH-001: 12 occurrences
|
|
739
|
+
|
|
740
|
+
### v0.0.2 (2025-10-25)
|
|
741
|
+
- **REFINED**: Added password reset flow requirements
|
|
742
|
+
- **REFINED**: Clarified token lifetime constraints
|
|
743
|
+
- **AUTHOR**: @Goos
|
|
744
|
+
|
|
745
|
+
### v0.0.1 (2025-10-23)
|
|
746
|
+
- **INITIAL**: JWT authentication SPEC draft created
|
|
747
|
+
- **AUTHOR**: @Goos
|
|
748
|
+
- **SCOPE**: User authentication, token generation, token validation
|
|
749
|
+
- **CONTEXT**: Requirement from Q4 2025 product roadmap
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
---
|
|
753
|
+
|
|
754
|
+
## TAG Integration
|
|
755
|
+
|
|
756
|
+
### TAG Block Format
|
|
757
|
+
|
|
758
|
+
Every SPEC document starts with a TAG block after the title:
|
|
759
|
+
|
|
760
|
+
```markdown
|
|
761
|
+
# @SPEC:AUTH-001: JWT Authentication System
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
### TAG Chain References
|
|
765
|
+
|
|
766
|
+
Link related TAGs in the SPEC:
|
|
767
|
+
|
|
768
|
+
```markdown
|
|
769
|
+
## Traceability (@TAG Chain)
|
|
770
|
+
|
|
771
|
+
### TAG Chain Structure
|
|
772
|
+
```
|
|
773
|
+
@SPEC:AUTH-001 (this document)
|
|
774
|
+
↓
|
|
775
|
+
@TEST:AUTH-001 (tests/auth/service.test.ts)
|
|
776
|
+
↓
|
|
777
|
+
@CODE:AUTH-001 (src/auth/service.ts, src/auth/token-manager.ts)
|
|
778
|
+
↓
|
|
779
|
+
@DOC:AUTH-001 (docs/api/authentication.md)
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
### Verification Commands
|
|
783
|
+
```bash
|
|
784
|
+
# Verify SPEC TAG
|
|
785
|
+
rg '@SPEC:AUTH-001' -n .moai/specs/
|
|
786
|
+
|
|
787
|
+
# Check duplicate IDs
|
|
788
|
+
rg '@SPEC:AUTH' -n .moai/specs/
|
|
789
|
+
rg 'AUTH-001' -n
|
|
790
|
+
|
|
791
|
+
# Full TAG chain scan
|
|
792
|
+
rg '@(SPEC|TEST|CODE|DOC):AUTH-001' -n
|
|
793
|
+
```
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
---
|
|
797
|
+
|
|
798
|
+
## Pre-Submission Validation Checklist
|
|
799
|
+
|
|
800
|
+
### Metadata Validation
|
|
801
|
+
|
|
802
|
+
```bash
|
|
803
|
+
# Check all required fields present
|
|
804
|
+
rg "^(id|version|status|created|updated|author|priority):" .moai/specs/SPEC-AUTH-001/spec.md
|
|
805
|
+
|
|
806
|
+
# Verify author format (@Handle)
|
|
807
|
+
rg "^author: @[A-Z]" .moai/specs/SPEC-AUTH-001/spec.md
|
|
808
|
+
|
|
809
|
+
# Verify version format (0.x.y)
|
|
810
|
+
rg "^version: 0\.\d+\.\d+" .moai/specs/SPEC-AUTH-001/spec.md
|
|
811
|
+
|
|
812
|
+
# Check duplicate IDs
|
|
813
|
+
rg "@SPEC:AUTH-001" -n .moai/specs/
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
### Content Validation
|
|
817
|
+
|
|
818
|
+
- [ ] **YAML Front Matter**: All 7 required fields present
|
|
819
|
+
- [ ] **TAG Block**: `@SPEC:{ID}` in title matches metadata `id`
|
|
820
|
+
- [ ] **HISTORY Section**: Present with v0.0.1 INITIAL entry
|
|
821
|
+
- [ ] **Environment Section**: Execution context, tech stack, constraints defined
|
|
822
|
+
- [ ] **Assumptions Section**: At least 3 key assumptions documented
|
|
823
|
+
- [ ] **Requirements Section**: All 5 EARS patterns used (or justified omissions)
|
|
824
|
+
- [ ] **Acceptance Criteria**: Testable criteria for each requirement
|
|
825
|
+
- [ ] **Traceability Section**: TAG chain structure documented
|
|
826
|
+
|
|
827
|
+
### EARS Syntax Validation
|
|
828
|
+
|
|
829
|
+
- [ ] **Ubiquitous**: Uses "shall" + capability
|
|
830
|
+
- [ ] **Event-driven**: Starts with "WHEN [trigger]"
|
|
831
|
+
- [ ] **State-driven**: Starts with "WHILE [state]"
|
|
832
|
+
- [ ] **Optional**: Starts with "WHERE [feature]", uses "can" not "shall"
|
|
833
|
+
- [ ] **Constraints**: Uses "IF-THEN" or direct constraint statement
|
|
834
|
+
|
|
835
|
+
### Quality Checks
|
|
836
|
+
|
|
837
|
+
- [ ] **No duplicate IDs**: `rg "AUTH-001" -n` returns only this SPEC
|
|
838
|
+
- [ ] **Consistent naming**: Directory name matches `SPEC-{ID}`
|
|
839
|
+
- [ ] **Complete HISTORY**: Each version has date, author, description
|
|
840
|
+
- [ ] **Clear requirements**: Each requirement is testable and unambiguous
|
|
841
|
+
- [ ] **Proper versioning**: Follows semantic versioning lifecycle
|
|
842
|
+
|
|
843
|
+
---
|
|
844
|
+
|
|
845
|
+
## Common Pitfalls & Prevention
|
|
846
|
+
|
|
847
|
+
### Pitfall 1: Changing ID After Assignment
|
|
848
|
+
|
|
849
|
+
**Problem**: Changing `id: AUTH-001` to `id: AUTH-002` after SPEC is created
|
|
850
|
+
|
|
851
|
+
**Impact**:
|
|
852
|
+
- Breaks TAG chain references
|
|
853
|
+
- Orphans existing code/tests
|
|
854
|
+
- Git history loss
|
|
855
|
+
|
|
856
|
+
**Prevention**:
|
|
857
|
+
```bash
|
|
858
|
+
# Always check for existing IDs before assignment
|
|
859
|
+
rg "@SPEC:AUTH" -n .moai/specs/
|
|
860
|
+
rg "AUTH-001" -n
|
|
861
|
+
|
|
862
|
+
# IDs are IMMUTABLE once assigned
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
### Pitfall 2: Skipping HISTORY Updates
|
|
866
|
+
|
|
867
|
+
**Problem**: Updating SPEC content without adding HISTORY entry
|
|
868
|
+
|
|
869
|
+
**Impact**:
|
|
870
|
+
- Lost change rationale
|
|
871
|
+
- Unclear version progression
|
|
872
|
+
- Audit trail gaps
|
|
873
|
+
|
|
874
|
+
**Prevention**:
|
|
875
|
+
```markdown
|
|
876
|
+
# ALWAYS update HISTORY when changing content
|
|
877
|
+
## HISTORY
|
|
878
|
+
|
|
879
|
+
### v0.0.2 (2025-10-25) ← New entry
|
|
880
|
+
- **REFINED**: Added XYZ requirement
|
|
881
|
+
- **AUTHOR**: @YourHandle
|
|
882
|
+
|
|
883
|
+
### v0.0.1 (2025-10-23)
|
|
884
|
+
- **INITIAL**: First draft
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
### Pitfall 3: Wrong Version Number Progression
|
|
888
|
+
|
|
889
|
+
**Problem**: Jumping from v0.0.1 to v1.0.0 without intermediate versions
|
|
890
|
+
|
|
891
|
+
**Impact**:
|
|
892
|
+
- Version lifecycle broken
|
|
893
|
+
- Unclear maturity signal
|
|
894
|
+
- Stakeholder confusion
|
|
895
|
+
|
|
896
|
+
**Prevention**:
|
|
897
|
+
```markdown
|
|
898
|
+
# Follow version lifecycle strictly
|
|
899
|
+
v0.0.1 → v0.0.2 → ... → v0.1.0 → v0.1.1 → ... → v1.0.0
|
|
900
|
+
(draft) (draft) (completed) (patches) (stable)
|
|
901
|
+
|
|
902
|
+
# Never skip stages without justification in HISTORY
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
### Pitfall 4: Vague EARS Requirements
|
|
906
|
+
|
|
907
|
+
**Problem**: "The system shall be fast and user-friendly"
|
|
908
|
+
|
|
909
|
+
**Impact**:
|
|
910
|
+
- Untestable requirements
|
|
911
|
+
- Ambiguous acceptance criteria
|
|
912
|
+
- Implementation confusion
|
|
913
|
+
|
|
914
|
+
**Prevention**:
|
|
915
|
+
```markdown
|
|
916
|
+
# Bad
|
|
917
|
+
**UR-001**: The system shall be fast.
|
|
918
|
+
|
|
919
|
+
# Good
|
|
920
|
+
**UR-001**: The system shall respond to API requests within 200ms for 95% of requests.
|
|
921
|
+
|
|
922
|
+
# Bad
|
|
923
|
+
**ER-001**: WHEN user logs in, system should work.
|
|
924
|
+
|
|
925
|
+
# Good
|
|
926
|
+
**ER-001**: WHEN a user submits valid credentials, the system shall issue a JWT token with 15-minute expiry.
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
### Pitfall 5: Missing Author `@` Prefix
|
|
930
|
+
|
|
931
|
+
**Problem**: `author: Goos` instead of `author: @Goos`
|
|
932
|
+
|
|
933
|
+
**Impact**:
|
|
934
|
+
- Validation failures
|
|
935
|
+
- Inconsistent attribution
|
|
936
|
+
- GitHub linking broken
|
|
937
|
+
|
|
938
|
+
**Prevention**:
|
|
939
|
+
```yaml
|
|
940
|
+
# Wrong
|
|
941
|
+
author: Goos
|
|
942
|
+
author: goos
|
|
943
|
+
|
|
944
|
+
# Correct
|
|
945
|
+
author: @Goos
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
### Pitfall 6: Duplicate SPEC IDs
|
|
949
|
+
|
|
950
|
+
**Problem**: Creating `SPEC-AUTH-001` when it already exists
|
|
951
|
+
|
|
952
|
+
**Impact**:
|
|
953
|
+
- TAG chain collisions
|
|
954
|
+
- Ambiguous references
|
|
955
|
+
- Merge conflicts
|
|
956
|
+
|
|
957
|
+
**Prevention**:
|
|
958
|
+
```bash
|
|
959
|
+
# ALWAYS check before creating new SPEC
|
|
960
|
+
rg "@SPEC:AUTH-001" -n .moai/specs/
|
|
961
|
+
rg "AUTH-001" -n
|
|
962
|
+
|
|
963
|
+
# Use Explore agent to find similar SPECs
|
|
964
|
+
# Increment number if domain exists
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
### Pitfall 7: Mixing EARS Patterns
|
|
968
|
+
|
|
969
|
+
**Problem**: "WHEN user is logged in, WHILE session is active, the system shall..."
|
|
970
|
+
|
|
971
|
+
**Impact**:
|
|
972
|
+
- Confusing logic
|
|
973
|
+
- Hard to test
|
|
974
|
+
- Maintenance burden
|
|
975
|
+
|
|
976
|
+
**Prevention**:
|
|
977
|
+
```markdown
|
|
978
|
+
# Bad (mixed patterns)
|
|
979
|
+
**ER-001**: WHEN user logs in, WHILE session is active, the system shall allow access.
|
|
980
|
+
|
|
981
|
+
# Good (separate requirements)
|
|
982
|
+
**ER-001**: WHEN a user logs in successfully, the system shall create a session.
|
|
983
|
+
**SR-001**: WHILE a session is active, the system shall allow access to protected resources.
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
---
|
|
987
|
+
|
|
988
|
+
## Integration with `/alfred:1-plan`
|
|
989
|
+
|
|
990
|
+
### Workflow Handoff
|
|
991
|
+
|
|
992
|
+
When `/alfred:1-plan` is invoked, the `spec-builder` agent uses this Skill to:
|
|
993
|
+
|
|
994
|
+
1. **Analyze** user request and project context
|
|
995
|
+
2. **Generate** SPEC candidates with proper structure
|
|
996
|
+
3. **Validate** metadata completeness
|
|
997
|
+
4. **Create** `.moai/specs/SPEC-{ID}/spec.md` with EARS requirements
|
|
998
|
+
5. **Initialize** Git workflow (feature branch, Draft PR)
|
|
999
|
+
|
|
1000
|
+
### spec-builder Integration Points
|
|
1001
|
+
|
|
1002
|
+
```markdown
|
|
1003
|
+
Phase 1: SPEC Candidate Generation
|
|
1004
|
+
↓ (uses moai-spec-authoring for metadata structure)
|
|
1005
|
+
Phase 2: User Approval
|
|
1006
|
+
↓
|
|
1007
|
+
Phase 3: SPEC File Creation
|
|
1008
|
+
↓ (applies EARS templates from this Skill)
|
|
1009
|
+
Phase 4: Git Workflow Initialization
|
|
1010
|
+
↓
|
|
1011
|
+
Phase 5: Handoff to /alfred:2-run
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
### Agent Collaboration
|
|
1015
|
+
|
|
1016
|
+
- **spec-builder**: Generates SPEC using this Skill's templates
|
|
1017
|
+
- **tag-agent**: Validates TAG format and uniqueness
|
|
1018
|
+
- **trust-checker**: Verifies metadata completeness
|
|
1019
|
+
- **git-manager**: Creates feature branch and Draft PR
|
|
1020
|
+
|
|
1021
|
+
---
|
|
1022
|
+
|
|
1023
|
+
## Validation Commands
|
|
1024
|
+
|
|
1025
|
+
### Quick Validation Script
|
|
1026
|
+
|
|
1027
|
+
```bash
|
|
1028
|
+
#!/usr/bin/env bash
|
|
1029
|
+
# validate-spec.sh - SPEC validation helper
|
|
1030
|
+
|
|
1031
|
+
SPEC_DIR="$1"
|
|
1032
|
+
|
|
1033
|
+
echo "Validating SPEC: $SPEC_DIR"
|
|
1034
|
+
|
|
1035
|
+
# Check required fields
|
|
1036
|
+
echo -n "Required fields... "
|
|
1037
|
+
rg "^(id|version|status|created|updated|author|priority):" "$SPEC_DIR/spec.md" | wc -l | grep -q "7" && echo "✅" || echo "❌"
|
|
1038
|
+
|
|
1039
|
+
# Check author format
|
|
1040
|
+
echo -n "Author format... "
|
|
1041
|
+
rg "^author: @[A-Z]" "$SPEC_DIR/spec.md" > /dev/null && echo "✅" || echo "❌"
|
|
1042
|
+
|
|
1043
|
+
# Check version format
|
|
1044
|
+
echo -n "Version format... "
|
|
1045
|
+
rg "^version: 0\.\d+\.\d+" "$SPEC_DIR/spec.md" > /dev/null && echo "✅" || echo "❌"
|
|
1046
|
+
|
|
1047
|
+
# Check HISTORY section
|
|
1048
|
+
echo -n "HISTORY section... "
|
|
1049
|
+
rg "^## HISTORY" "$SPEC_DIR/spec.md" > /dev/null && echo "✅" || echo "❌"
|
|
1050
|
+
|
|
1051
|
+
# Check TAG block
|
|
1052
|
+
echo -n "TAG block... "
|
|
1053
|
+
rg "^# @SPEC:" "$SPEC_DIR/spec.md" > /dev/null && echo "✅" || echo "❌"
|
|
1054
|
+
|
|
1055
|
+
# Check duplicate IDs
|
|
1056
|
+
SPEC_ID=$(basename "$SPEC_DIR" | sed 's/SPEC-//')
|
|
1057
|
+
DUPLICATE_COUNT=$(rg "@SPEC:$SPEC_ID" -n .moai/specs/ | wc -l)
|
|
1058
|
+
echo -n "Duplicate ID check... "
|
|
1059
|
+
[ "$DUPLICATE_COUNT" -eq 1 ] && echo "✅" || echo "❌ (found $DUPLICATE_COUNT occurrences)"
|
|
1060
|
+
|
|
1061
|
+
echo "Validation complete!"
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
### Usage
|
|
1065
|
+
|
|
1066
|
+
```bash
|
|
1067
|
+
# Validate single SPEC
|
|
1068
|
+
./validate-spec.sh .moai/specs/SPEC-AUTH-001
|
|
1069
|
+
|
|
1070
|
+
# Validate all SPECs
|
|
1071
|
+
for spec in .moai/specs/SPEC-*/; do
|
|
1072
|
+
./validate-spec.sh "$spec"
|
|
1073
|
+
done
|
|
1074
|
+
```
|
|
1075
|
+
|
|
1076
|
+
---
|
|
1077
|
+
|
|
1078
|
+
## Advanced Patterns
|
|
1079
|
+
|
|
1080
|
+
### Pattern: Versioned Requirements
|
|
1081
|
+
|
|
1082
|
+
When a requirement changes across versions, document the evolution:
|
|
1083
|
+
|
|
1084
|
+
```markdown
|
|
1085
|
+
### v0.2.0 (2025-11-15)
|
|
1086
|
+
**UR-001** (CHANGED): The system shall respond within 200ms for 99% of requests.
|
|
1087
|
+
- Previous (v0.1.0): 95% of requests
|
|
1088
|
+
- Rationale: Performance improvement based on user feedback
|
|
1089
|
+
|
|
1090
|
+
### v0.1.0 (2025-10-30)
|
|
1091
|
+
**UR-001**: The system shall respond within 200ms for 95% of requests.
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
### Pattern: Requirement Traceability Matrix
|
|
1095
|
+
|
|
1096
|
+
Link requirements to test cases explicitly:
|
|
1097
|
+
|
|
1098
|
+
```markdown
|
|
1099
|
+
## Requirements Traceability Matrix
|
|
1100
|
+
|
|
1101
|
+
| Req ID | Description | Test Cases | Status |
|
|
1102
|
+
|--------|-------------|------------|--------|
|
|
1103
|
+
| UR-001 | JWT authentication | test_authenticate_valid_user | ✅ |
|
|
1104
|
+
| ER-001 | Token issuance | test_token_generation | ✅ |
|
|
1105
|
+
| ER-002 | Token expiry | test_expired_token_rejection | ✅ |
|
|
1106
|
+
| SR-001 | Authenticated access | test_protected_route_access | ✅ |
|
|
1107
|
+
| C-001 | Token lifetime | test_token_expiry_constraint | ✅ |
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
### Pattern: Decision Log
|
|
1111
|
+
|
|
1112
|
+
Document architectural decisions within SPEC:
|
|
1113
|
+
|
|
1114
|
+
```markdown
|
|
1115
|
+
## Decision Log
|
|
1116
|
+
|
|
1117
|
+
### Decision 1: JWT vs Session Cookies (2025-10-23)
|
|
1118
|
+
**Context**: Need stateless authentication for microservices
|
|
1119
|
+
**Decision**: Use JWT tokens
|
|
1120
|
+
**Alternatives Considered**:
|
|
1121
|
+
- Session cookies (rejected: stateful, not scalable)
|
|
1122
|
+
- OAuth 2.0 (deferred: too complex for MVP)
|
|
1123
|
+
**Consequences**:
|
|
1124
|
+
- ✅ Stateless, scalable
|
|
1125
|
+
- ✅ Cross-service authentication
|
|
1126
|
+
- ❌ Token revocation complexity
|
|
1127
|
+
|
|
1128
|
+
### Decision 2: Token Expiry 15min (2025-10-24)
|
|
1129
|
+
**Context**: Balance security vs UX
|
|
1130
|
+
**Decision**: 15-minute access token, 7-day refresh token
|
|
1131
|
+
**Rationale**: Industry standard, security best practice
|
|
1132
|
+
**References**: OWASP JWT best practices
|
|
1133
|
+
```
|
|
1134
|
+
|
|
1135
|
+
---
|
|
1136
|
+
|
|
1137
|
+
## Examples Gallery
|
|
1138
|
+
|
|
1139
|
+
### Example 1: Complete Minimal SPEC
|
|
1140
|
+
|
|
1141
|
+
```markdown
|
|
1142
|
+
---
|
|
1143
|
+
id: HELLO-001
|
|
1144
|
+
version: 0.0.1
|
|
1145
|
+
status: draft
|
|
1146
|
+
created: 2025-10-23
|
|
1147
|
+
updated: 2025-10-23
|
|
1148
|
+
author: @Goos
|
|
1149
|
+
priority: low
|
|
1150
|
+
---
|
|
1151
|
+
|
|
1152
|
+
# @SPEC:HELLO-001: Hello World API
|
|
1153
|
+
|
|
1154
|
+
## HISTORY
|
|
1155
|
+
|
|
1156
|
+
### v0.0.1 (2025-10-23)
|
|
1157
|
+
- **INITIAL**: Hello World API SPEC draft created
|
|
1158
|
+
- **AUTHOR**: @Goos
|
|
1159
|
+
|
|
1160
|
+
## Environment
|
|
1161
|
+
|
|
1162
|
+
**Runtime**: Node.js 20.x
|
|
1163
|
+
**Framework**: Express.js
|
|
1164
|
+
|
|
1165
|
+
## Assumptions
|
|
1166
|
+
|
|
1167
|
+
1. Single endpoint required
|
|
1168
|
+
2. No authentication needed
|
|
1169
|
+
3. JSON response format
|
|
1170
|
+
|
|
1171
|
+
## Requirements
|
|
1172
|
+
|
|
1173
|
+
### Ubiquitous Requirements
|
|
1174
|
+
|
|
1175
|
+
**UR-001**: The system shall provide a GET /hello endpoint.
|
|
1176
|
+
|
|
1177
|
+
### Event-driven Requirements
|
|
1178
|
+
|
|
1179
|
+
**ER-001**: WHEN a GET request is sent to /hello, the system shall return JSON `{"message": "Hello, World!"}`.
|
|
1180
|
+
|
|
1181
|
+
### Constraints
|
|
1182
|
+
|
|
1183
|
+
**C-001**: Response time shall not exceed 50ms.
|
|
1184
|
+
```
|
|
1185
|
+
|
|
1186
|
+
### Example 2: Production-Grade SPEC
|
|
1187
|
+
|
|
1188
|
+
See `SPEC-BRAND-001` or `SPEC-TRUST-001` in `.moai/specs/` for comprehensive examples with all optional fields, dependency graphs, and detailed HISTORY sections.
|
|
1189
|
+
|
|
1190
|
+
---
|
|
1191
|
+
|
|
1192
|
+
## Troubleshooting
|
|
1193
|
+
|
|
1194
|
+
### Issue: "Duplicate SPEC ID detected"
|
|
1195
|
+
|
|
1196
|
+
**Symptoms**: `rg "@SPEC:AUTH-001" -n` returns multiple results
|
|
1197
|
+
|
|
1198
|
+
**Solution**:
|
|
1199
|
+
```bash
|
|
1200
|
+
# Find all occurrences
|
|
1201
|
+
rg "@SPEC:AUTH-001" -n .moai/specs/
|
|
1202
|
+
|
|
1203
|
+
# Choose one SPEC to keep, rename others
|
|
1204
|
+
# Update TAG references in code/tests
|
|
1205
|
+
rg '@SPEC:AUTH-001' -l src/ tests/ | xargs sed -i 's/@SPEC:AUTH-001/@SPEC:AUTH-002/g'
|
|
1206
|
+
```
|
|
1207
|
+
|
|
1208
|
+
### Issue: "Version number doesn't match status"
|
|
1209
|
+
|
|
1210
|
+
**Symptoms**: `status: completed` but `version: 0.0.1`
|
|
1211
|
+
|
|
1212
|
+
**Solution**:
|
|
1213
|
+
```yaml
|
|
1214
|
+
# Update version to reflect completion
|
|
1215
|
+
version: 0.1.0 # Implementation complete
|
|
1216
|
+
status: completed
|
|
1217
|
+
```
|
|
1218
|
+
|
|
1219
|
+
### Issue: "HISTORY section missing version"
|
|
1220
|
+
|
|
1221
|
+
**Symptoms**: Content changed but no new HISTORY entry
|
|
1222
|
+
|
|
1223
|
+
**Solution**:
|
|
1224
|
+
```markdown
|
|
1225
|
+
## HISTORY
|
|
1226
|
+
|
|
1227
|
+
### v0.0.2 (2025-10-25) ← Add new entry
|
|
1228
|
+
- **REFINED**: Updated XYZ requirement
|
|
1229
|
+
- **AUTHOR**: @YourHandle
|
|
1230
|
+
|
|
1231
|
+
### v0.0.1 (2025-10-23)
|
|
1232
|
+
- **INITIAL**: First draft
|
|
1233
|
+
```
|
|
1234
|
+
|
|
1235
|
+
---
|
|
1236
|
+
|
|
1237
|
+
## References
|
|
1238
|
+
|
|
1239
|
+
### Internal Documentation
|
|
1240
|
+
|
|
1241
|
+
- `.moai/memory/spec-metadata.md` - Complete metadata reference
|
|
1242
|
+
- `.moai/memory/development-guide.md` - SPEC-First TDD workflow
|
|
1243
|
+
- `moai-foundation-ears` Skill - EARS syntax guide
|
|
1244
|
+
- `moai-foundation-specs` Skill - Metadata validation
|
|
1245
|
+
|
|
1246
|
+
### External Resources
|
|
1247
|
+
|
|
1248
|
+
- EARS Official: Mavin, Wilkinson, et al. (2009) "Easy Approach to Requirements Syntax"
|
|
1249
|
+
- QRA Guide: https://qracorp.com/guides_checklists/the-easy-approach-to-requirements-syntax-ears/
|
|
1250
|
+
- Jama Software: EARS Notation Guide
|
|
1251
|
+
|
|
1252
|
+
---
|
|
1253
|
+
|
|
1254
|
+
## Changelog
|
|
1255
|
+
|
|
1256
|
+
- **v1.0.0** (2025-10-23): Initial comprehensive SPEC authoring Skill
|
|
1257
|
+
- 7 required + 9 optional metadata fields
|
|
1258
|
+
- 5 EARS patterns with examples
|
|
1259
|
+
- Version lifecycle guide
|
|
1260
|
+
- Pre-submission validation checklist
|
|
1261
|
+
- Common pitfalls prevention
|
|
1262
|
+
- Integration with `/alfred:1-plan`
|
|
1263
|
+
|
|
1264
|
+
---
|
|
1265
|
+
|
|
1266
|
+
## Works Well With
|
|
1267
|
+
|
|
1268
|
+
- `moai-foundation-ears` - EARS syntax patterns
|
|
1269
|
+
- `moai-foundation-specs` - Metadata validation
|
|
1270
|
+
- `moai-foundation-tags` - TAG system integration
|
|
1271
|
+
- `moai-alfred-spec-metadata-validation` - Automated validation
|
|
1272
|
+
- `spec-builder` agent - SPEC generation workflow
|
|
1273
|
+
|
|
1274
|
+
---
|
|
1275
|
+
|
|
1276
|
+
## Best Practices Summary
|
|
1277
|
+
|
|
1278
|
+
✅ **DO**:
|
|
1279
|
+
- Check for duplicate IDs before creating new SPEC
|
|
1280
|
+
- Update HISTORY with every content change
|
|
1281
|
+
- Follow version lifecycle strictly (0.0.1 → 0.1.0 → 1.0.0)
|
|
1282
|
+
- Use `@` prefix for author field
|
|
1283
|
+
- Write testable, measurable requirements
|
|
1284
|
+
- Include all 7 required metadata fields
|
|
1285
|
+
- Use EARS patterns consistently
|
|
1286
|
+
|
|
1287
|
+
❌ **DON'T**:
|
|
1288
|
+
- Change SPEC ID after assignment
|
|
1289
|
+
- Skip HISTORY updates
|
|
1290
|
+
- Jump version numbers without justification
|
|
1291
|
+
- Write vague requirements ("fast", "user-friendly")
|
|
1292
|
+
- Mix multiple EARS patterns in one requirement
|
|
1293
|
+
- Forget to validate before submission
|
|
1294
|
+
- Create duplicate SPEC IDs
|
|
1295
|
+
|
|
1296
|
+
---
|
|
1297
|
+
|
|
1298
|
+
**Last Updated**: 2025-10-23
|
|
1299
|
+
**Maintained By**: MoAI-ADK Team
|
|
1300
|
+
**Support**: Invoke `/alfred:1-plan` for guided SPEC creation
|