ai-core-framework 0.1.0
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-plugin/plugin.json +21 -0
- package/.codex-plugin/plugin.json +35 -0
- package/.cursor-plugin/plugin.json +22 -0
- package/README.md +173 -0
- package/bin/ai-core-framework.js +110 -0
- package/core/README.md +162 -0
- package/core/agents/README.md +32 -0
- package/core/agents/business-analyst.md +269 -0
- package/core/agents/developer.md +375 -0
- package/core/agents/qa-tester.md +477 -0
- package/core/agents/scrum-master.md +136 -0
- package/core/agents/tech-lead.md +345 -0
- package/core/config/backlog.schema.json +38 -0
- package/core/config/docs-policy.default.json +37 -0
- package/core/config/release.schema.json +120 -0
- package/core/config/ticket.schema.json +253 -0
- package/core/rules/00-global-rules.md +373 -0
- package/core/rules/01-git-workflow.md +388 -0
- package/core/rules/02-code-quality.md +77 -0
- package/core/rules/03-security.md +78 -0
- package/core/rules/04-documentation.md +72 -0
- package/core/rules/05-testing-mandatory.md +374 -0
- package/core/rules/06-approval-gates.md +388 -0
- package/core/rules/07-definition-of-ready.md +112 -0
- package/core/rules/08-definition-of-done.md +149 -0
- package/core/scripts/ai-core.sh +456 -0
- package/core/scripts/generate-views.sh +210 -0
- package/core/scripts/install-codex-prompts.sh +127 -0
- package/core/scripts/log-user-request.sh +113 -0
- package/core/scripts/setup-project.sh +183 -0
- package/core/scripts/sync-platforms.sh +322 -0
- package/core/scripts/validate-audit-log.sh +73 -0
- package/core/scripts/validate-docs.sh +365 -0
- package/core/scripts/validate-permissions.sh +132 -0
- package/core/scripts/validate-state.sh +611 -0
- package/core/scripts/workflow.sh +513 -0
- package/core/skills/README.md +21 -0
- package/core/skills/ai-core-commands/SKILL.md +86 -0
- package/core/skills/brainstorming/SKILL.md +40 -0
- package/core/skills/development-implement-task/SKILL.md +308 -0
- package/core/skills/executing-ticket/SKILL.md +28 -0
- package/core/skills/git-branch-status/SKILL.md +56 -0
- package/core/skills/git-cleanup-branches/SKILL.md +57 -0
- package/core/skills/git-scan-untracked/SKILL.md +50 -0
- package/core/skills/meta-generate-views/SKILL.md +54 -0
- package/core/skills/meta-request-log/SKILL.md +61 -0
- package/core/skills/meta-sprint-report/SKILL.md +59 -0
- package/core/skills/meta-sync-platforms/SKILL.md +53 -0
- package/core/skills/meta-ticket-health/SKILL.md +61 -0
- package/core/skills/meta-validate-audit-log/SKILL.md +42 -0
- package/core/skills/meta-validate-docs/SKILL.md +58 -0
- package/core/skills/meta-validate-permissions/SKILL.md +53 -0
- package/core/skills/meta-validate-state/SKILL.md +58 -0
- package/core/skills/planning-analyze-requirements/SKILL.md +471 -0
- package/core/skills/planning-backlog-status/SKILL.md +57 -0
- package/core/skills/planning-document-existing-requirements/SKILL.md +246 -0
- package/core/skills/planning-estimate-task/SKILL.md +60 -0
- package/core/skills/planning-groom-ticket/SKILL.md +442 -0
- package/core/skills/planning-mark-ready/SKILL.md +111 -0
- package/core/skills/planning-plan-refactor/SKILL.md +66 -0
- package/core/skills/planning-plan-sprint/SKILL.md +112 -0
- package/core/skills/planning-prioritize-backlog/SKILL.md +62 -0
- package/core/skills/planning-write-plan/SKILL.md +68 -0
- package/core/skills/project-detect-stack/SKILL.md +71 -0
- package/core/skills/project-discover-codebase/SKILL.md +74 -0
- package/core/skills/project-setup-project/SKILL.md +113 -0
- package/core/skills/qa-bug-status/SKILL.md +52 -0
- package/core/skills/qa-report-bug/SKILL.md +518 -0
- package/core/skills/qa-smoke-test/SKILL.md +387 -0
- package/core/skills/qa-triage-bug/SKILL.md +62 -0
- package/core/skills/qa-verify-fix/SKILL.md +446 -0
- package/core/skills/release-hotfix/SKILL.md +117 -0
- package/core/skills/release-release/SKILL.md +123 -0
- package/core/skills/release-rollback/SKILL.md +62 -0
- package/core/skills/review-create-pr/SKILL.md +418 -0
- package/core/skills/review-merge-pr/SKILL.md +425 -0
- package/core/skills/review-techlead-review/SKILL.md +547 -0
- package/core/skills/using-ai-core/SKILL.md +72 -0
- package/core/skills/verification-before-done/SKILL.md +35 -0
- package/core/skills/writing-implementation-plan/SKILL.md +45 -0
- package/core/templates/ci/ai-core-governance.yml +112 -0
- package/core/templates/ci/node-pnpm.yml +35 -0
- package/core/templates/pm/retrospective-template.md +47 -0
- package/core/templates/pm/sprint-plan-template.md +45 -0
- package/core/templates/pr/pull-request-template.md +247 -0
- package/core/templates/project/CODEOWNERS +11 -0
- package/core/templates/project/docs-policy.json +3 -0
- package/core/templates/project/project-config.yaml +137 -0
- package/core/templates/project/project-structure.yaml +76 -0
- package/core/templates/qa/bug-report-template.md +371 -0
- package/core/templates/qa/test-plan-template.md +57 -0
- package/core/templates/release/release-record-template.json +67 -0
- package/core/templates/requirements/PRD-template.md +58 -0
- package/core/templates/requirements/user-story-template.md +381 -0
- package/core/templates/technical/ADR-template.md +46 -0
- package/core/templates/technical/refactor-plan-template.md +84 -0
- package/core/templates/technical/tech-design-template.md +71 -0
- package/core/workflows/bug-lifecycle.md +56 -0
- package/core/workflows/feature-lifecycle.md +347 -0
- package/core/workflows/hotfix-lifecycle.md +65 -0
- package/core/workflows/sprint-lifecycle.md +56 -0
- package/lib/install-codex.js +85 -0
- package/package.json +36 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
# 🔒 RULE 01: Git Workflow (Strict)
|
|
2
|
+
|
|
3
|
+
> **Non-negotiable git discipline** for this project.
|
|
4
|
+
> Enforced by: pre-commit hooks + CI + agent rules.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🎯 Branching Strategy: GitHub Flow + Release branches
|
|
9
|
+
|
|
10
|
+
Small Agile team (2-5 people). Use **GitHub Flow** (simpler than Git Flow) with release branches for production releases.
|
|
11
|
+
|
|
12
|
+
### Branches
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
main ← production (stable, tagged releases)
|
|
16
|
+
↑
|
|
17
|
+
develop ← integration (latest features, passing CI)
|
|
18
|
+
↑
|
|
19
|
+
feature/* ← individual work (branched from develop)
|
|
20
|
+
bugfix/* ← bug fixes in sprint (branched from develop)
|
|
21
|
+
hotfix/* ← emergency production fixes (branched from main)
|
|
22
|
+
release/* ← release preparation (branched from develop)
|
|
23
|
+
chore/* ← non-code: docs, deps, config
|
|
24
|
+
refactor/* ← code cleanup, no behavior change
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Flow
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Normal feature:
|
|
31
|
+
develop → feature/TICKET-XXX → PR → merge to develop → release/vX.Y.Z → main
|
|
32
|
+
|
|
33
|
+
Hotfix:
|
|
34
|
+
main → hotfix/TICKET-XXX → PR → merge to main → cherry-pick to develop
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🔒 Rules
|
|
40
|
+
|
|
41
|
+
### RULE GIT-001: Branch naming strict
|
|
42
|
+
|
|
43
|
+
**Format**: `<type>/TICKET-<number>-<slug>`
|
|
44
|
+
|
|
45
|
+
Regex: `^(feature|bugfix|hotfix|chore|refactor|release)/(TICKET-\d+-[a-z0-9-]+|v\d+\.\d+\.\d+)$`
|
|
46
|
+
|
|
47
|
+
**Examples**:
|
|
48
|
+
- ✅ `feature/TICKET-042-password-reset`
|
|
49
|
+
- ✅ `bugfix/TICKET-089-login-500`
|
|
50
|
+
- ✅ `hotfix/TICKET-101-payment-crash`
|
|
51
|
+
- ✅ `chore/TICKET-050-upgrade-node-20`
|
|
52
|
+
- ✅ `release/v1.2.0`
|
|
53
|
+
- ❌ `my-branch`
|
|
54
|
+
- ❌ `TICKET-042` (missing type prefix)
|
|
55
|
+
- ❌ `feature/password-reset` (missing TICKET-XXX)
|
|
56
|
+
- ❌ `Feature/TICKET-042-X` (uppercase)
|
|
57
|
+
- ❌ `feature/TICKET-042-password_reset` (underscore instead of dash)
|
|
58
|
+
|
|
59
|
+
**Slug rules**:
|
|
60
|
+
- lowercase only
|
|
61
|
+
- kebab-case (dash separator)
|
|
62
|
+
- ≤ 50 chars
|
|
63
|
+
- Descriptive (not `fix-thing`)
|
|
64
|
+
|
|
65
|
+
### RULE GIT-002: Protected branches
|
|
66
|
+
|
|
67
|
+
**MUST NOT** direct push to:
|
|
68
|
+
- `main`
|
|
69
|
+
- `master`
|
|
70
|
+
- `develop`
|
|
71
|
+
- `release/*`
|
|
72
|
+
- `staging`
|
|
73
|
+
- `production`
|
|
74
|
+
|
|
75
|
+
Changes to protected branches MUST go through PR only.
|
|
76
|
+
|
|
77
|
+
**Enforced by**: GitHub branch protection + local pre-push hook.
|
|
78
|
+
|
|
79
|
+
### RULE GIT-003: Conventional Commits
|
|
80
|
+
|
|
81
|
+
**Format**:
|
|
82
|
+
```
|
|
83
|
+
<type>(<scope>): <subject>
|
|
84
|
+
|
|
85
|
+
[optional body]
|
|
86
|
+
|
|
87
|
+
[optional footer(s)]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Types** (allowed):
|
|
91
|
+
- `feat`: new feature
|
|
92
|
+
- `fix`: bug fix
|
|
93
|
+
- `docs`: documentation only
|
|
94
|
+
- `style`: formatting (no code change)
|
|
95
|
+
- `refactor`: code cleanup (no feature, no bug fix)
|
|
96
|
+
- `perf`: performance improvement
|
|
97
|
+
- `test`: adding/modifying tests
|
|
98
|
+
- `chore`: maintenance (deps, config)
|
|
99
|
+
- `build`: build system changes
|
|
100
|
+
- `ci`: CI pipeline changes
|
|
101
|
+
- `revert`: revert previous commit
|
|
102
|
+
|
|
103
|
+
**Scope**: `TICKET-XXX` or module name. Required.
|
|
104
|
+
|
|
105
|
+
**Subject**:
|
|
106
|
+
- Imperative mood: "add", "fix", not "added", "fixes"
|
|
107
|
+
- Lowercase first letter
|
|
108
|
+
- No period at end
|
|
109
|
+
- ≤ 72 chars
|
|
110
|
+
|
|
111
|
+
**Examples**:
|
|
112
|
+
- ✅ `feat(TICKET-042): add password reset endpoint`
|
|
113
|
+
- ✅ `fix(TICKET-089): handle null email in login`
|
|
114
|
+
- ✅ `refactor(auth): extract token validation to middleware`
|
|
115
|
+
- ✅ `docs(TICKET-050): update API docs for v2 endpoints`
|
|
116
|
+
- ❌ `Added password reset` (no type, capitalized)
|
|
117
|
+
- ❌ `feat: stuff` (no scope, vague)
|
|
118
|
+
- ❌ `feat(TICKET-042): Add password reset.` (capital, period)
|
|
119
|
+
|
|
120
|
+
### RULE GIT-004: Commit body for complex changes
|
|
121
|
+
|
|
122
|
+
If commit changes > 50 lines or touch > 3 files, **MUST** include a body explaining WHY, not only WHAT.
|
|
123
|
+
|
|
124
|
+
Format:
|
|
125
|
+
```
|
|
126
|
+
feat(TICKET-042): add password reset endpoint
|
|
127
|
+
|
|
128
|
+
Implements password reset flow with email verification:
|
|
129
|
+
- New endpoint: POST /auth/reset-password
|
|
130
|
+
- Rate limiting: 5 req/hour/email
|
|
131
|
+
- Token: crypto.randomBytes(32), 24h expiration
|
|
132
|
+
- Email: HTML template with reset link
|
|
133
|
+
|
|
134
|
+
Decisions:
|
|
135
|
+
- Using JWT instead of DB session (stateless, horizontal scale)
|
|
136
|
+
- SendGrid chosen over AWS SES (team familiarity)
|
|
137
|
+
|
|
138
|
+
Refs: ADR-0012
|
|
139
|
+
Closes: TICKET-042
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### RULE GIT-005: Atomic commits
|
|
143
|
+
|
|
144
|
+
1 commit = 1 logical change.
|
|
145
|
+
|
|
146
|
+
**MUST NOT**:
|
|
147
|
+
- Mix feature + refactor
|
|
148
|
+
- Mix 2 features
|
|
149
|
+
- Commit partial work called "WIP" (squash before push to shared branches)
|
|
150
|
+
- Commit broken code (must at least compile, preferably tests pass)
|
|
151
|
+
|
|
152
|
+
**SHOULD**:
|
|
153
|
+
- Separate commits for tests vs implementation (TDD)
|
|
154
|
+
- Separate refactor commits
|
|
155
|
+
|
|
156
|
+
### RULE GIT-006: No force push to shared
|
|
157
|
+
|
|
158
|
+
**MUST NOT** `git push --force` to:
|
|
159
|
+
- Any branch someone else collaborates on
|
|
160
|
+
- `main`, `develop`, release branches
|
|
161
|
+
|
|
162
|
+
**MAY** force push to own feature branch pre-review.
|
|
163
|
+
|
|
164
|
+
**Use `--force-with-lease`** instead of `--force` to avoid overwriting others work.
|
|
165
|
+
|
|
166
|
+
### RULE GIT-007: Keep branches short-lived
|
|
167
|
+
|
|
168
|
+
Feature branches **SHOULD** merge within ≤ 5 days.
|
|
169
|
+
|
|
170
|
+
If > 5 days:
|
|
171
|
+
- Sync with develop daily (`git rebase develop` or `git merge develop`)
|
|
172
|
+
- Consider splitting ticket
|
|
173
|
+
- Flag in standup
|
|
174
|
+
|
|
175
|
+
Rule enforced by: `/branch-status` flag stale branches.
|
|
176
|
+
|
|
177
|
+
### RULE GIT-008: Squash merge strategy
|
|
178
|
+
|
|
179
|
+
PR merge strategy: **Squash and merge** (default).
|
|
180
|
+
|
|
181
|
+
Reasons:
|
|
182
|
+
- Clean develop/main history
|
|
183
|
+
- 1 ticket = 1 commit in history
|
|
184
|
+
- Easier revert
|
|
185
|
+
|
|
186
|
+
**Exception**: Release PRs use merge commits (preserve history).
|
|
187
|
+
|
|
188
|
+
**Squash commit message format**:
|
|
189
|
+
```
|
|
190
|
+
<type>(TICKET-XXX): <PR title> (#<PR-number>)
|
|
191
|
+
|
|
192
|
+
<PR description summary>
|
|
193
|
+
|
|
194
|
+
Refs: ADR-XXXX (if any)
|
|
195
|
+
Closes: TICKET-XXX
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### RULE GIT-009: Delete branch after merge
|
|
199
|
+
|
|
200
|
+
Merged feature/bugfix branches **MUST** be deleted (local + remote).
|
|
201
|
+
|
|
202
|
+
Auto via GitHub setting: "Automatically delete head branches".
|
|
203
|
+
|
|
204
|
+
Local cleanup: `/cleanup-branches` (weekly).
|
|
205
|
+
|
|
206
|
+
### RULE GIT-010: No sensitive data
|
|
207
|
+
|
|
208
|
+
**MUST NEVER** commit:
|
|
209
|
+
- API keys, tokens
|
|
210
|
+
- Passwords (including in tests)
|
|
211
|
+
- Private keys (`.pem`, `.key`, `.ppk`)
|
|
212
|
+
- `.env` files with real values
|
|
213
|
+
- Customer PII
|
|
214
|
+
- Internal URLs with credentials embedded
|
|
215
|
+
|
|
216
|
+
**Pre-commit hook scans for patterns**:
|
|
217
|
+
```
|
|
218
|
+
pattern | action
|
|
219
|
+
----------------------------------|----------
|
|
220
|
+
[a-z0-9]{32,} | warn (might be token)
|
|
221
|
+
api[_-]?key\s*[:=] | block
|
|
222
|
+
password\s*[:=]\s*['"](?!mock) | block
|
|
223
|
+
AKIA[A-Z0-9]{16} | block (AWS key)
|
|
224
|
+
-----BEGIN .* PRIVATE KEY | block
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**If accidentally committed**:
|
|
228
|
+
1. **IMMEDIATELY** rotate the secret
|
|
229
|
+
2. Remove from history: `git filter-repo` or BFG
|
|
230
|
+
3. Force push (coordinate with team)
|
|
231
|
+
4. Post-mortem: add pattern to pre-commit hook
|
|
232
|
+
|
|
233
|
+
### RULE GIT-011: Sign commits (if configured)
|
|
234
|
+
|
|
235
|
+
If project has GPG signing enabled:
|
|
236
|
+
- **MUST** sign all commits
|
|
237
|
+
- CI rejects unsigned commits
|
|
238
|
+
- See `docs/git-signing-setup.md`
|
|
239
|
+
|
|
240
|
+
Optional for projects not yet set up.
|
|
241
|
+
|
|
242
|
+
### RULE GIT-012: No merge commits in feature branch
|
|
243
|
+
|
|
244
|
+
**MUST** use rebase, or merge from develop, never from feature, to sync.
|
|
245
|
+
|
|
246
|
+
**MUST NOT**:
|
|
247
|
+
```
|
|
248
|
+
# BAD
|
|
249
|
+
git checkout feature/TICKET-042
|
|
250
|
+
git merge feature/TICKET-043 # ❌ merging another feature
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**OK**:
|
|
254
|
+
```
|
|
255
|
+
# Good: sync with develop
|
|
256
|
+
git checkout feature/TICKET-042
|
|
257
|
+
git rebase develop
|
|
258
|
+
# or
|
|
259
|
+
git merge develop
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### RULE GIT-013: PR requirements
|
|
263
|
+
|
|
264
|
+
Every PR **MUST**:
|
|
265
|
+
- [ ] Link ticket (auto from branch name)
|
|
266
|
+
- [ ] Pass all CI checks
|
|
267
|
+
- [ ] Have ≥1 approval from tech-lead
|
|
268
|
+
- [ ] Coverage ≥ 80% diff
|
|
269
|
+
- [ ] All review comments resolved
|
|
270
|
+
- [ ] No merge conflicts
|
|
271
|
+
- [ ] Filled PR template
|
|
272
|
+
|
|
273
|
+
See `templates/pr/pull-request-template.md`.
|
|
274
|
+
|
|
275
|
+
### RULE GIT-014: Release tagging
|
|
276
|
+
|
|
277
|
+
Release tags **MUST** follow SemVer: `v<major>.<minor>.<patch>`.
|
|
278
|
+
|
|
279
|
+
**When to bump**:
|
|
280
|
+
- **Major**: Breaking API change
|
|
281
|
+
- **Minor**: New feature, backward compatible
|
|
282
|
+
- **Patch**: Bug fix, backward compatible
|
|
283
|
+
|
|
284
|
+
Examples:
|
|
285
|
+
- `v1.0.0` - first stable release
|
|
286
|
+
- `v1.1.0` - added feature
|
|
287
|
+
- `v1.1.1` - fixed bug
|
|
288
|
+
- `v2.0.0` - breaking change
|
|
289
|
+
|
|
290
|
+
**Tag format**: Annotated tags with message:
|
|
291
|
+
```bash
|
|
292
|
+
git tag -a v1.2.0 -m "Release v1.2.0: Password reset + rate limiting"
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### RULE GIT-015: Gitignore hygiene
|
|
296
|
+
|
|
297
|
+
`.gitignore` **MUST** include:
|
|
298
|
+
- Build artifacts (`dist/`, `build/`, `*.pyc`)
|
|
299
|
+
- Dependencies (`node_modules/`, `venv/`, `.env`)
|
|
300
|
+
- IDE files (`.vscode/`, `.idea/` - except shared settings)
|
|
301
|
+
- OS files (`.DS_Store`, `Thumbs.db`)
|
|
302
|
+
- Logs (`*.log`)
|
|
303
|
+
- Local configs (`.env.local`, `.env.*.local`)
|
|
304
|
+
|
|
305
|
+
**MUST NOT** ignore:
|
|
306
|
+
- `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml` (commit lockfiles)
|
|
307
|
+
- `requirements.txt`, `Pipfile.lock`, `poetry.lock`
|
|
308
|
+
- CI config files (`.github/`, `.gitlab-ci.yml`)
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## 🔧 Pre-commit Hooks (recommended)
|
|
313
|
+
|
|
314
|
+
Setup in `.githooks/pre-commit`:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
#!/bin/bash
|
|
318
|
+
set -e
|
|
319
|
+
|
|
320
|
+
# 1. Lint check
|
|
321
|
+
npm run lint --silent || { echo "Lint failed"; exit 1; }
|
|
322
|
+
|
|
323
|
+
# 2. Type check (if TS)
|
|
324
|
+
npm run typecheck --silent || { echo "Type check failed"; exit 1; }
|
|
325
|
+
|
|
326
|
+
# 3. Run tests on changed files
|
|
327
|
+
npm run test:changed --silent || { echo "Tests failed"; exit 1; }
|
|
328
|
+
|
|
329
|
+
# 4. Scan for secrets
|
|
330
|
+
git diff --cached | grep -iE "(api[_-]?key|password|token|secret)\s*[:=]\s*['\"][^'\"]{8,}" && {
|
|
331
|
+
echo "❌ Possible secret detected in diff"
|
|
332
|
+
exit 1
|
|
333
|
+
} || true
|
|
334
|
+
|
|
335
|
+
# 5. Validate commit message (if using commit-msg hook)
|
|
336
|
+
# See .githooks/commit-msg
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## 🔧 Commit-msg Hook
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
#!/bin/bash
|
|
343
|
+
commit_msg=$(cat "$1")
|
|
344
|
+
|
|
345
|
+
# Conventional commits regex
|
|
346
|
+
pattern='^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([a-zA-Z0-9_-]+\))?: .{1,72}$'
|
|
347
|
+
|
|
348
|
+
if ! echo "$commit_msg" | head -1 | grep -qE "$pattern"; then
|
|
349
|
+
echo "❌ Commit message doesn't follow Conventional Commits format"
|
|
350
|
+
echo "Expected: <type>(scope): <subject>"
|
|
351
|
+
echo "Example: feat(TICKET-042): add password reset endpoint"
|
|
352
|
+
exit 1
|
|
353
|
+
fi
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## 🚨 Violation Consequences
|
|
359
|
+
|
|
360
|
+
### Minor violations (warning)
|
|
361
|
+
- Typo in commit message → amend
|
|
362
|
+
- Branch name slightly wrong → rename before PR
|
|
363
|
+
|
|
364
|
+
### Major violations (block)
|
|
365
|
+
- Direct push to main → blocked by GitHub protection
|
|
366
|
+
- Secrets committed → CI block, rotate secret, rewrite history
|
|
367
|
+
- Missing tests → PR blocked by CI
|
|
368
|
+
- Force push to shared branch → escalate to tech-lead
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## 💡 Common Issues & Fixes
|
|
373
|
+
|
|
374
|
+
| Issue | Fix |
|
|
375
|
+
|-------|-----|
|
|
376
|
+
| Merge conflict | `git rebase develop`, resolve, `git rebase --continue` |
|
|
377
|
+
| Committed to wrong branch | `git reset HEAD~N`, `git stash`, checkout correct branch, `git stash pop` |
|
|
378
|
+
| Committed secret | Revoke NOW, `git filter-repo`, force push, post-mortem |
|
|
379
|
+
| Typo in commit message | `git commit --amend` (if not pushed) |
|
|
380
|
+
| Forgot ticket in branch name | Rename: `git branch -m new-name` |
|
|
381
|
+
| Long-lived branch gone stale | `git rebase develop`, resolve conflicts incrementally |
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
**Version**: 1.0.0
|
|
386
|
+
**Last updated**: 2026-04-18
|
|
387
|
+
**Maintainer**: Tech Lead
|
|
388
|
+
**Next review**: End of each sprint
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# 🔒 RULE 02: Code Quality
|
|
2
|
+
|
|
3
|
+
> Applies to all production code, tests, scripts, and configuration changes. Quality gates are blocking unless explicitly labeled as advisory.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🎯 Core Principle
|
|
8
|
+
|
|
9
|
+
Code must be understandable, maintainable, testable, and safe to evolve. Passing tests alone is not sufficient.
|
|
10
|
+
|
|
11
|
+
## 🔒 Rules
|
|
12
|
+
|
|
13
|
+
### RULE CQ-001: Small cohesive units
|
|
14
|
+
Functions SHOULD be under 50 lines and files SHOULD be under 500 lines. If exceeded, document why or refactor.
|
|
15
|
+
|
|
16
|
+
### RULE CQ-002: Complexity limit
|
|
17
|
+
Cyclomatic complexity MUST NOT exceed the configured threshold in `config/project-config.yaml`, default 10.
|
|
18
|
+
|
|
19
|
+
### RULE CQ-003: Clear naming
|
|
20
|
+
Names MUST describe intent. Avoid vague names such as `data`, `thing`, `stuff`, `tmp`, except for narrow local use.
|
|
21
|
+
|
|
22
|
+
### RULE CQ-004: No dead code
|
|
23
|
+
Production changes MUST NOT introduce commented-out code, unused exports, unused variables, or unreachable branches.
|
|
24
|
+
|
|
25
|
+
### RULE CQ-005: Error handling required
|
|
26
|
+
External calls, parsing, IO, database access, and network calls MUST handle failure paths explicitly.
|
|
27
|
+
|
|
28
|
+
### RULE CQ-006: Type safety
|
|
29
|
+
Typed projects MUST NOT use unsafe escapes such as `any`, unchecked casts, or ignored compiler errors without a ticket reference and justification.
|
|
30
|
+
|
|
31
|
+
### RULE CQ-007: Logging discipline
|
|
32
|
+
Logs MUST be useful, structured where possible, and free of secrets or PII. Debug logs MUST NOT be committed unless guarded and justified.
|
|
33
|
+
|
|
34
|
+
### RULE CQ-008: Dependency discipline
|
|
35
|
+
New dependencies MUST have a purpose, license check, security check, and version pin. Prefer existing project dependencies.
|
|
36
|
+
|
|
37
|
+
### RULE CQ-009: Public interface stability
|
|
38
|
+
Changes to public APIs MUST preserve backward compatibility or document breaking change impact and migration path.
|
|
39
|
+
|
|
40
|
+
### RULE CQ-010: CI green is mandatory
|
|
41
|
+
Lint, format, type check, test, and security gates configured for the project MUST pass before review and merge.
|
|
42
|
+
|
|
43
|
+
## ✅ Examples
|
|
44
|
+
|
|
45
|
+
Good:
|
|
46
|
+
|
|
47
|
+
- Small function with single responsibility.
|
|
48
|
+
- Explicit error handling with actionable messages.
|
|
49
|
+
- Tests covering edge cases.
|
|
50
|
+
- Dependency added with reason and audit result.
|
|
51
|
+
|
|
52
|
+
Bad:
|
|
53
|
+
|
|
54
|
+
- Large function mixing validation, business logic, and IO.
|
|
55
|
+
- Swallowing errors with empty catch blocks.
|
|
56
|
+
- `TODO` without `TICKET-XXX`.
|
|
57
|
+
- Adding library for a trivial helper.
|
|
58
|
+
|
|
59
|
+
## 🛠️ Enforcement
|
|
60
|
+
|
|
61
|
+
- Agent self-review during `/implement-task`.
|
|
62
|
+
- Tech Lead review during `/techlead-review`.
|
|
63
|
+
- Hooks in `.githooks/pre-commit`.
|
|
64
|
+
- CI workflow in `.github/workflows/ci.yml`.
|
|
65
|
+
|
|
66
|
+
## 🚨 Failure Modes
|
|
67
|
+
|
|
68
|
+
If quality fails:
|
|
69
|
+
|
|
70
|
+
1. Keep ticket in current state.
|
|
71
|
+
2. Document failed gate.
|
|
72
|
+
3. Fix root cause.
|
|
73
|
+
4. Re-run tests and validation.
|
|
74
|
+
5. Re-request review only after gates pass.
|
|
75
|
+
|
|
76
|
+
**Version**: 1.0.0
|
|
77
|
+
**Owner**: Tech Lead
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# 🔒 RULE 03: Security
|
|
2
|
+
|
|
3
|
+
> Security rules apply to every agent, command, and code change. Security gates outrank delivery speed.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🎯 Core Principle
|
|
8
|
+
|
|
9
|
+
Protect users, data, infrastructure, and secrets by default. If security impact is unclear, escalate to Tech Lead before implementation.
|
|
10
|
+
|
|
11
|
+
## 🔒 Rules
|
|
12
|
+
|
|
13
|
+
### RULE SEC-001: No secrets in repository
|
|
14
|
+
MUST NOT commit tokens, passwords, private keys, certificates, `.env` files, customer data, or production credentials.
|
|
15
|
+
|
|
16
|
+
### RULE SEC-002: Least privilege
|
|
17
|
+
New permissions, scopes, IAM policies, database grants, and API keys MUST use least privilege and documented purpose.
|
|
18
|
+
|
|
19
|
+
### RULE SEC-003: Input validation
|
|
20
|
+
All external input MUST be validated at trust boundaries, including HTTP requests, jobs, webhooks, CLI args, uploaded files, and third-party payloads.
|
|
21
|
+
|
|
22
|
+
### RULE SEC-004: Authentication and authorization
|
|
23
|
+
Protected operations MUST check both authentication and authorization. Do not rely on frontend hiding or route naming.
|
|
24
|
+
|
|
25
|
+
### RULE SEC-005: Sensitive data handling
|
|
26
|
+
PII, credentials, tokens, payment data, and confidential business data MUST be minimized, encrypted where required, and never logged.
|
|
27
|
+
|
|
28
|
+
### RULE SEC-006: Dependency security
|
|
29
|
+
New or upgraded dependencies MUST be audited. High or critical vulnerabilities block merge unless formally accepted with mitigation.
|
|
30
|
+
|
|
31
|
+
### RULE SEC-007: OWASP review
|
|
32
|
+
User-facing and API changes MUST be checked against relevant OWASP Top 10 risks: injection, broken auth, access control, crypto failures, SSRF, XSS, insecure design, and logging/monitoring gaps.
|
|
33
|
+
|
|
34
|
+
### RULE SEC-008: Secure defaults
|
|
35
|
+
Features MUST default to safe behavior. Feature flags, debug modes, permissive CORS, public buckets, or relaxed auth MUST NOT be enabled by default.
|
|
36
|
+
|
|
37
|
+
### RULE SEC-009: Auditability
|
|
38
|
+
Security-relevant actions SHOULD emit audit events without sensitive payloads.
|
|
39
|
+
|
|
40
|
+
### RULE SEC-010: Incident escalation
|
|
41
|
+
Suspected data exposure, credential leak, production compromise, or auth bypass MUST trigger immediate escalation and likely `/hotfix`.
|
|
42
|
+
|
|
43
|
+
## ✅ Examples
|
|
44
|
+
|
|
45
|
+
Good:
|
|
46
|
+
|
|
47
|
+
- Password reset endpoint returns generic response for unknown email.
|
|
48
|
+
- API checks ownership before returning resource.
|
|
49
|
+
- Tokens are stored hashed or encrypted based on use case.
|
|
50
|
+
- Logs include request ID, not raw token.
|
|
51
|
+
|
|
52
|
+
Bad:
|
|
53
|
+
|
|
54
|
+
- `console.log(req.headers.authorization)`.
|
|
55
|
+
- Admin endpoint protected only by hidden UI.
|
|
56
|
+
- S3 bucket opened publicly for quick test.
|
|
57
|
+
- Dependency added despite critical CVE.
|
|
58
|
+
|
|
59
|
+
## 🛠️ Enforcement
|
|
60
|
+
|
|
61
|
+
- Pre-commit secret scanning.
|
|
62
|
+
- CI secret/dependency/SAST scans.
|
|
63
|
+
- Tech Lead security review.
|
|
64
|
+
- QA negative tests for auth and access control.
|
|
65
|
+
|
|
66
|
+
## 🚨 Failure Modes
|
|
67
|
+
|
|
68
|
+
If security gate fails:
|
|
69
|
+
|
|
70
|
+
1. Stop delivery.
|
|
71
|
+
2. Document risk and affected files.
|
|
72
|
+
3. Remove or mitigate issue.
|
|
73
|
+
4. Rotate exposed credentials if needed.
|
|
74
|
+
5. Add regression test or scanning rule.
|
|
75
|
+
6. Resume only after Tech Lead approval.
|
|
76
|
+
|
|
77
|
+
**Version**: 1.0.0
|
|
78
|
+
**Owner**: Tech Lead / Security Reviewer
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# 🔒 RULE 04: Documentation
|
|
2
|
+
|
|
3
|
+
> Documentation is part of the deliverable. Undocumented behavior is unfinished behavior.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🎯 Core Principle
|
|
8
|
+
|
|
9
|
+
Anyone maintaining or using the system should understand what changed, how to run it, how to test it, and how to recover from failure.
|
|
10
|
+
|
|
11
|
+
## 🔒 Rules
|
|
12
|
+
|
|
13
|
+
### RULE DOC-001: Public APIs documented
|
|
14
|
+
Public functions, classes, CLI commands, endpoints, events, and packages MUST document purpose, inputs, outputs, errors, and examples.
|
|
15
|
+
|
|
16
|
+
### RULE DOC-002: README stays current
|
|
17
|
+
If setup, scripts, environment variables, architecture, or developer workflow changes, the relevant README MUST be updated in the same PR.
|
|
18
|
+
|
|
19
|
+
### RULE DOC-003: ADR for architecture decisions
|
|
20
|
+
Major architecture decisions MUST have an ADR covering context, decision, alternatives, consequences, and rollback considerations.
|
|
21
|
+
|
|
22
|
+
### RULE DOC-004: Changelog for user-visible change
|
|
23
|
+
Features, bug fixes, breaking changes, migrations, and operational changes SHOULD be reflected in changelog or release notes.
|
|
24
|
+
|
|
25
|
+
### RULE DOC-005: Runbooks for operations
|
|
26
|
+
Deployments, rollbacks, migrations, incident response, and recurring operations MUST have runbook steps when applicable.
|
|
27
|
+
|
|
28
|
+
### RULE DOC-006: Comments explain why
|
|
29
|
+
Inline comments SHOULD explain non-obvious reasoning, constraints, or tradeoffs. Do not comment obvious syntax.
|
|
30
|
+
|
|
31
|
+
### RULE DOC-007: Examples must be safe
|
|
32
|
+
Documentation examples MUST NOT include real secrets, customer data, internal-only hostnames, or misleading insecure patterns.
|
|
33
|
+
|
|
34
|
+
### RULE DOC-008: Generated docs are marked
|
|
35
|
+
Generated docs MUST identify source and generation command to avoid manual drift.
|
|
36
|
+
|
|
37
|
+
### RULE DOC-009: Docs are testable where possible
|
|
38
|
+
Commands and examples SHOULD be copy-pasteable and verified during review.
|
|
39
|
+
|
|
40
|
+
### RULE DOC-010: Outdated docs block release
|
|
41
|
+
Known misleading docs for changed behavior MUST be fixed before release.
|
|
42
|
+
|
|
43
|
+
## ✅ Required Documentation by Change Type
|
|
44
|
+
|
|
45
|
+
| Change type | Required docs |
|
|
46
|
+
|-------------|---------------|
|
|
47
|
+
| New API | API reference, examples, error cases |
|
|
48
|
+
| Setup change | README and env example |
|
|
49
|
+
| Architecture decision | ADR |
|
|
50
|
+
| Migration | Runbook and rollback notes |
|
|
51
|
+
| User-visible feature | Release notes and help docs if applicable |
|
|
52
|
+
| Hotfix | Incident summary and follow-up ticket |
|
|
53
|
+
|
|
54
|
+
## 🛠️ Enforcement
|
|
55
|
+
|
|
56
|
+
- Developer checklist in `/implement-task`.
|
|
57
|
+
- PR template in `core/templates/pr/`.
|
|
58
|
+
- Tech Lead review.
|
|
59
|
+
- Release checklist in `/release`.
|
|
60
|
+
- `bash scripts/validate-docs.sh` blocks missing documentation evidence in CI and pre-commit.
|
|
61
|
+
- DONE tickets require machine-readable `dod_checklist`, documentation paths, and QA evidence where applicable.
|
|
62
|
+
|
|
63
|
+
## 🚨 Failure Modes
|
|
64
|
+
|
|
65
|
+
If docs are missing:
|
|
66
|
+
|
|
67
|
+
1. Keep PR in review.
|
|
68
|
+
2. Add docs or create explicit follow-up only for non-blocking internal gaps.
|
|
69
|
+
3. Re-run review checklist.
|
|
70
|
+
|
|
71
|
+
**Version**: 1.0.0
|
|
72
|
+
**Owner**: Tech Lead + Scrum Master
|