sdlc-kit 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +13 -0
- package/.claude-plugin/plugin.json +12 -0
- package/CHANGELOG.md +44 -0
- package/LICENSE +21 -0
- package/README.md +168 -2
- package/commands/adr.md +15 -0
- package/commands/handoff-pr.md +20 -0
- package/commands/handoff.md +14 -0
- package/commands/pickup.md +9 -0
- package/commands/qa.md +15 -0
- package/commands/review.md +16 -0
- package/commands/ship.md +15 -0
- package/commands/spec.md +11 -0
- package/commands/start.md +20 -0
- package/dist/bin/cli.js +71 -0
- package/dist/lib/installer.js +693 -0
- package/dist/lib/statusline.js +46 -0
- package/package.json +54 -4
- package/skills/sdlc-orchestrator/SKILL.md +44 -0
- package/skills/sdlc-workflow/SKILL.md +98 -0
- package/skills/sdlc-workflow/references/architecture-checklist.md +26 -0
- package/skills/sdlc-workflow/references/clean-code.md +15 -0
- package/skills/sdlc-workflow/references/database-hygiene.md +20 -0
- package/skills/sdlc-workflow/references/developer-habits.md +29 -0
- package/skills/sdlc-workflow/references/incident-response.md +25 -0
- package/skills/sdlc-workflow/references/monolith-and-microservices.md +20 -0
- package/skills/sdlc-workflow/references/quality-gates.md +35 -0
- package/skills/sdlc-workflow/references/security-checklist.md +20 -0
- package/templates/local/LOCAL_PROMPT.md +8 -0
- package/templates/project/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- package/templates/project/AGENTS.md +15 -0
- package/templates/project/CLAUDE.md +1 -0
- package/templates/project/docs/INDEX.md +7 -0
- package/templates/project/docs/adr/TEMPLATE.md +16 -0
- package/templates/project/docs/plans/.gitkeep +1 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Claude Code status line: context window usage, so you know when to /handoff and /clear.
|
|
2
|
+
// Self-contained on purpose: the installer copies the compiled file to ~/.claude/ as-is.
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
const DIM = '\x1b[2m';
|
|
5
|
+
const RESET = '\x1b[0m';
|
|
6
|
+
function render(raw) {
|
|
7
|
+
let data = {};
|
|
8
|
+
try {
|
|
9
|
+
data = JSON.parse(raw || '{}');
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
// malformed input: fall through to an empty status line
|
|
13
|
+
}
|
|
14
|
+
const model = data.model?.display_name ?? '';
|
|
15
|
+
let cwd = data.workspace?.current_dir ?? data.cwd ?? '';
|
|
16
|
+
const home = os.homedir();
|
|
17
|
+
if (home && cwd.startsWith(home))
|
|
18
|
+
cwd = `~${cwd.slice(home.length)}`;
|
|
19
|
+
const used = Number(data.context_window?.used_percentage);
|
|
20
|
+
if (data.context_window?.used_percentage === undefined || Number.isNaN(used)) {
|
|
21
|
+
return `${DIM}${cwd} ${model}${RESET}`;
|
|
22
|
+
}
|
|
23
|
+
const pct = Math.trunc(used);
|
|
24
|
+
let color = '\x1b[32m';
|
|
25
|
+
let label = `ctx ${pct}%`;
|
|
26
|
+
if (pct >= 85) {
|
|
27
|
+
color = '\x1b[31m';
|
|
28
|
+
label = `ctx ${pct}% (/handoff & /clear!)`;
|
|
29
|
+
}
|
|
30
|
+
else if (pct >= 70) {
|
|
31
|
+
color = '\x1b[33m';
|
|
32
|
+
label = `ctx ${pct}% (/handoff)`;
|
|
33
|
+
}
|
|
34
|
+
else if (pct >= 50) {
|
|
35
|
+
color = '\x1b[36m';
|
|
36
|
+
}
|
|
37
|
+
return `${DIM}${cwd}${RESET} ${color}${label}${RESET} ${DIM}${model}${RESET}`;
|
|
38
|
+
}
|
|
39
|
+
let input = '';
|
|
40
|
+
process.stdin.setEncoding('utf8');
|
|
41
|
+
process.stdin.on('data', (chunk) => {
|
|
42
|
+
input += chunk;
|
|
43
|
+
});
|
|
44
|
+
process.stdin.on('end', () => {
|
|
45
|
+
process.stdout.write(render(input));
|
|
46
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdlc-kit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Universal, token-efficient SDLC workflow skills, commands, and orchestrator protocol for Claude Code, Codex, Antigravity, and Local LLMs.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"sdlc-kit": "dist/bin/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"!dist/test",
|
|
16
|
+
"skills",
|
|
17
|
+
"commands",
|
|
18
|
+
"templates",
|
|
19
|
+
".claude-plugin",
|
|
20
|
+
"README.md",
|
|
21
|
+
"CHANGELOG.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20.0.0"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"prepare": "npm run build",
|
|
31
|
+
"test": "npm run build && node --test dist/test/cli.test.js"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"claude-code",
|
|
35
|
+
"codex",
|
|
36
|
+
"antigravity",
|
|
37
|
+
"llm",
|
|
38
|
+
"sdlc",
|
|
39
|
+
"agent-skills",
|
|
40
|
+
"token-optimization",
|
|
41
|
+
"orchestrator"
|
|
42
|
+
],
|
|
43
|
+
"author": "sumitroajiprabowo",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/sumitroajiprabowo/sdlc-kit.git"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/sumitroajiprabowo/sdlc-kit/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/sumitroajiprabowo/sdlc-kit#readme",
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^22.20.6",
|
|
54
|
+
"typescript": "~5.9.0"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sdlc-orchestrator
|
|
3
|
+
description: "Token-safe multi-agent orchestrator protocol where a Planner decomposes tasks, scoped Workers execute in fresh contexts with compact under-30-line handoffs, and a Verifier checks diffs and tests. Use when coordinating subagents, swarms, or multi-model pipelines."
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# SDLC Orchestrator Protocol (Token-Safe Multi-Agent)
|
|
8
|
+
|
|
9
|
+
Follow this contract whenever coordinating multiple agents (subagents, swarms, or Planner/Worker/Verifier pipelines) so context never explodes.
|
|
10
|
+
|
|
11
|
+
## 1. Roles & Model Tiering
|
|
12
|
+
|
|
13
|
+
- **Planner / Orchestrator** (strongest reasoning model): reads Issue/spec, writes `docs/plans/<id>.md` if needed, splits work into independent subtasks, reviews final diffs.
|
|
14
|
+
- **Worker** (fast, cost-effective model — e.g., Sonnet, Codex, Local LLM): implements **exactly 1 subtask** in a fresh context, runs targeted tests, returns a `<30-line` report.
|
|
15
|
+
- **Verifier / QA** (fast model): inspects `git diff`, runs lint/typecheck/tests, checks 5 UI states (if FE) and security hygiene, returns `PASS` or `FAIL` with exact failing lines.
|
|
16
|
+
|
|
17
|
+
## 2. Fresh-Context Briefing Rule (Critical)
|
|
18
|
+
|
|
19
|
+
NEVER forward the orchestrator's full conversation history to a worker. Every worker brief must contain ONLY:
|
|
20
|
+
1. **Subtask goal** (1–3 sentences)
|
|
21
|
+
2. **Owned files / directories** (explicit paths)
|
|
22
|
+
3. **Contract / Acceptance Criteria** (3–5 bullets)
|
|
23
|
+
4. **Exact verification command** (e.g., `go test ./internal/auth -run TestLogin`)
|
|
24
|
+
|
|
25
|
+
## 3. Concurrency & Git Isolation
|
|
26
|
+
|
|
27
|
+
- Parallel workers MUST own **disjoint files** or run in **isolated git worktrees / branches**.
|
|
28
|
+
- Never merge two workers' changes without running targeted verification on the combined state.
|
|
29
|
+
|
|
30
|
+
## 4. Standard Worker Report (<30 Lines)
|
|
31
|
+
|
|
32
|
+
Every worker must reply using this compact format:
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
- **Status**: DONE | BLOCKED
|
|
36
|
+
- **Files Modified**: `path/a`, `path/b`
|
|
37
|
+
- **Verification**: `<command>` -> PASS/FAIL (<=10 lines output)
|
|
38
|
+
- **Notes / Risks**: 1–2 lines (or "None")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 5. Escalation Circuit Breaker
|
|
42
|
+
|
|
43
|
+
- If a worker fails the same verification **twice**, STOP retrying.
|
|
44
|
+
- Return the exact error (<=15 lines) to the Planner/User rather than looping until the context window fills up.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sdlc-workflow
|
|
3
|
+
description: "Universal, token-efficient SDLC playbook from repo setup to production, covering milestones, feature slicing, frontend 5-state design, QA pyramid, bugfix vs production hotfix, CI/CD, and zero-downtime migrations. Use when planning a feature or milestone, handling a bug or hotfix, setting up a repo, or shipping a PR."
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# SDLC Workflow (0 to Production — Universal & Token-Safe)
|
|
8
|
+
|
|
9
|
+
## Command Loop
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
/spec (big features) → /start #id
|
|
13
|
+
→ (complex task: use strong Planner model → approve)
|
|
14
|
+
→ Fast Executor model + targeted tests
|
|
15
|
+
→ ctx ≥70%: /handoff → /clear → /pickup (personal)
|
|
16
|
+
→ team handoff: push WIP → /handoff-pr (Draft PR / Issue comment)
|
|
17
|
+
→ key arch decision: /adr <title>
|
|
18
|
+
→ /qa → /review → /ship → review + CI → merge → /clear
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Phase 0 — Repo Foundation
|
|
22
|
+
|
|
23
|
+
- Keep `CLAUDE.md` / `AGENTS.md` thin (<4 KB): stack, build/test/lint commands, link to `docs/INDEX.md`.
|
|
24
|
+
- Maintain `docs/`: `INDEX.md` (1-line per doc), `adr/`, `plans/`, `runbooks/`.
|
|
25
|
+
- Path-scope `.claude/rules/*.md` with `paths:` YAML frontmatter so unrelated rules never load.
|
|
26
|
+
- `.gitignore`: exclude `.env`, `CLAUDE.local.md`, `.claude/HANDOFF.md`, `.claude/settings.local.json`.
|
|
27
|
+
- Protect `main`: require PR + green CI + PR template.
|
|
28
|
+
|
|
29
|
+
## Phase 1 — Planning & Milestone Rule
|
|
30
|
+
|
|
31
|
+
- **No Milestone**: small feature (1–2 PRs, ≤1 day), routine bug, or hotfix → 1 Issue → `/start #id` → `/ship`.
|
|
32
|
+
- **Use a Milestone**: big feature (≥3 Issues, cross-service DB+BE+FE, or >2–3 days) or team sprint.
|
|
33
|
+
- **Big feature slicing** (1 dedicated planning session):
|
|
34
|
+
1. Write short spec in `docs/plans/<feature>.md` + `/adr` for key decisions.
|
|
35
|
+
2. Split into ordered small issues (`1 Issue = 1 PR = 1–2 Sessions`):
|
|
36
|
+
- Issue 1 (Data): backward-compatible DB migration + model/repo + unit tests.
|
|
37
|
+
- Issue 2 (Backend): API endpoints + logic + integration tests + API spec.
|
|
38
|
+
- Issue 3 (Frontend): UI behind a **Feature Flag** + 5 UI states + component tests.
|
|
39
|
+
- Issue 4 (QA & Go-Live): E2E critical flows + enable Feature Flag.
|
|
40
|
+
3. Clear context (`/clear`) before starting Issue 1.
|
|
41
|
+
|
|
42
|
+
## Phase 2 — Frontend Design & Contract-First
|
|
43
|
+
|
|
44
|
+
- Keep design tokens in code (CSS vars / Tailwind / UI kit) + path-scoped design rules.
|
|
45
|
+
- Every FE issue must cover **5 UI States**: Default, Loading, Empty, Error, Responsive/A11y.
|
|
46
|
+
- Lock API / TypeScript schema first so BE & FE work in parallel.
|
|
47
|
+
- **Token rule**: after any visual/screenshot inspection, `/handoff` → `/clear` so images do not linger in context.
|
|
48
|
+
|
|
49
|
+
## Phase 3 — Daily Execution & Token Discipline
|
|
50
|
+
|
|
51
|
+
- Launch the agent inside the target service directory (not monorepo root unless cross-service).
|
|
52
|
+
- For files >200 lines, locate symbols with Grep first or read targeted line ranges (`offset`/`limit`).
|
|
53
|
+
- Run targeted tests only (`go test ./pkg -run TestX`, `vitest run file`, `pytest -k test_x`) and bound Bash logs (`| tail -n 50`).
|
|
54
|
+
- **Personal handoff**: `/handoff` → `/clear` → `/pickup` (`.claude/HANDOFF.md`, <60 lines).
|
|
55
|
+
- **Team handoff**: push WIP branch → `/handoff-pr` (<40-line summary to PR/Issue).
|
|
56
|
+
|
|
57
|
+
## Phase 4 — QA Pyramid (Token-Safe)
|
|
58
|
+
|
|
59
|
+
1. Static & Typecheck (linters, typecheck, format) — every PR.
|
|
60
|
+
2. **~70% Unit & Component tests** — every PR.
|
|
61
|
+
3. **~20% API / Contract tests** — every PR.
|
|
62
|
+
4. **~10% E2E Critical Flows** via CLI test runner (e.g. `npx playwright test --reporter=line`, NOT interactive browser screenshot dumps) — critical PRs & Staging.
|
|
63
|
+
5. **Staging / Preview UAT**: file QA bugs as structured Issues (repro steps, expected vs actual, 5–10 line error).
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Phase 5 — Bugs, Hotfixes & Refactors
|
|
68
|
+
|
|
69
|
+
- **Normal Bug**: `fix/<id>-<slug>` from `main` → reproduce → write failing regression test → fix → `/ship`.
|
|
70
|
+
- **Prod Hotfix**:
|
|
71
|
+
1. Rollback first if faster to restore service.
|
|
72
|
+
2. Branch `hotfix/<slug>` from the **production release tag** (never from a feature branch).
|
|
73
|
+
3. Minimal diff only (**NO refactors**) + regression test.
|
|
74
|
+
4. Fast-track `/ship` → deploy → **back-merge / cherry-pick** into `main` → write 10–15 line post-mortem.
|
|
75
|
+
- **Refactor**: separate PR from features; ensure existing tests are green first.
|
|
76
|
+
|
|
77
|
+
## Phase 6 — CI/CD, Release, Migrations & Prod Guardrails
|
|
78
|
+
|
|
79
|
+
- **CI PR Gate**: secret scan, lint/typecheck, unit/integration tests, artifact/container build + vulnerability scan. Debug failed CI with `gh run view <id> --log-failed | tail -n 80`.
|
|
80
|
+
- **Release**: Build once immutable image/artifact (`sha-<commit>` or `@sha256:...`, **NEVER `:latest`**); Conventional Commits + SemVer.
|
|
81
|
+
- **CD**: Auto-deploy Staging → smoke/E2E → Approval Gate → promote exact same artifact/digest to Prod (Rolling Update with readiness probe / Canary) → watch Golden Signals (5xx, latency, traffic, resources) 10–15m.
|
|
82
|
+
- **Zero-Downtime DB Migrations (Expand & Contract)**:
|
|
83
|
+
- Release 1: add nullable/default column, write both.
|
|
84
|
+
- Release 2: backfill + switch reads.
|
|
85
|
+
- Release 3: drop old column after old instances are gone.
|
|
86
|
+
- **Instant Rollback**: revert GitOps image tag or `rollout undo` — never rebuild during an outage.
|
|
87
|
+
- **Hard Safety Rule**: AI agents NEVER run destructive infra or DB commands (`kubectl apply`, `helm upgrade`, `ALTER/DROP`) directly against Production — all prod changes go through Git PR → CI → CD.
|
|
88
|
+
- **Production Pillars**: structured logs + alerts, feature flags, encrypted secrets (Vault/SOPS/ESO), automated DB backups + restore drills, automated dependency updates, load tests for high-traffic paths.
|
|
89
|
+
|
|
90
|
+
## References (On-Demand)
|
|
91
|
+
- [architecture-checklist.md](references/architecture-checklist.md) — Idempotency, failure design, backward compatibility, data integrity
|
|
92
|
+
- [monolith-and-microservices.md](references/monolith-and-microservices.md) — Modular monolith boundaries, service extraction, outbox, tracing, sagas
|
|
93
|
+
- [clean-code.md](references/clean-code.md) — Karpathy coding discipline, layer boundaries, error handling, simplicity
|
|
94
|
+
- [quality-gates.md](references/quality-gates.md) — Auto-detect format, lint, vulncheck, secret scan, API & load/stress QA
|
|
95
|
+
- [security-checklist.md](references/security-checklist.md) — Multi-tenant isolation, session hygiene, OWASP, PII masking, audit logs
|
|
96
|
+
- [database-hygiene.md](references/database-hygiene.md) — Query plans, lock-safe migrations, pooling, short transactions, backups
|
|
97
|
+
- [incident-response.md](references/incident-response.md) — SEV1–SEV4 tiers, 5-minute mitigation rule, comms, post-mortems
|
|
98
|
+
- [developer-habits.md](references/developer-habits.md) — Observability, blameless post-mortems, code deletion, tech debt budget, DoD
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Big Tech Architecture Checklist (On-Demand)
|
|
2
|
+
|
|
3
|
+
Consult this checklist when designing critical services (`/spec`, `/adr`) or reviewing mutations (`/review`).
|
|
4
|
+
|
|
5
|
+
## 1. Idempotency & Safe Retries
|
|
6
|
+
- Require an **idempotency key** on all critical mutations (payments, billing, provisioning, webhooks, async jobs) so retries or double-clicks never duplicate state.
|
|
7
|
+
- Set **explicit timeouts** on every outbound HTTP/RPC/DB call — never rely on infinite defaults.
|
|
8
|
+
- Use **bounded retries with exponential backoff + jitter** only for transient errors; add **circuit breakers** around flaky dependencies.
|
|
9
|
+
|
|
10
|
+
## 2. Design for Failure
|
|
11
|
+
Before coding any external integration or distributed workflow, answer:
|
|
12
|
+
1. What happens if the downstream service or DB hangs for 30s or returns 503?
|
|
13
|
+
2. What happens if the worker crashes mid-flight (partial failure)? Use transactions, outbox pattern, or compensating actions.
|
|
14
|
+
3. How can operators **replay or recover** safely without manual production DB edits?
|
|
15
|
+
|
|
16
|
+
## 3. Backward Compatibility & Contract Evolution
|
|
17
|
+
- Evolve APIs and event schemas **additively first**: add optional fields → deploy dual-support → deprecate old fields → remove only after all consumers migrate.
|
|
18
|
+
- Use **Expand & Contract** for zero-downtime DB migrations (add nullable → backfill & dual-write → switch reads → drop old column in a later release).
|
|
19
|
+
|
|
20
|
+
## 4. Boring Technology & Simplicity Bias
|
|
21
|
+
- Prefer proven, well-understood infrastructure (PostgreSQL, Redis, standard HTTP/gRPC, simple queues/cron) for core paths.
|
|
22
|
+
- Avoid premature abstractions or frameworks for single-use code.
|
|
23
|
+
|
|
24
|
+
## 5. Data Integrity & Security by Default
|
|
25
|
+
- Enforce invariants at the **database/schema level** (unique constraints, foreign keys, transactions, tenant isolation) — not only in application memory.
|
|
26
|
+
- Validate all external inputs at system boundaries and use least-privilege credentials/tokens.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Clean Code & LLM Coding Discipline (On-Demand)
|
|
2
|
+
|
|
3
|
+
Consult this reference when writing or reviewing code (`/review`).
|
|
4
|
+
|
|
5
|
+
## 1. Four Coding Discipline Principles (Anti-Over-Engineering)
|
|
6
|
+
1. **Think Before Coding**: State assumptions explicitly; surface ambiguities and tradeoffs instead of guessing silently; push back when a simpler approach exists.
|
|
7
|
+
2. **Simplicity First**: Write the minimum code that solves the problem. No speculative features, unrequested configurability, or single-use abstractions. If 200 lines can be 50, simplify.
|
|
8
|
+
3. **Surgical Changes**: Touch only lines that trace directly to the request. No drive-by refactors or unrelated reformatting. Clean up only unused imports/code created by your own edits.
|
|
9
|
+
4. **Goal-Driven Execution**: Turn tasks into verifiable criteria before coding (bugfix → failing regression test first; feature → explicit verification check per step).
|
|
10
|
+
|
|
11
|
+
## 2. Pragmatic Clean Code
|
|
12
|
+
- **Clean Layer Boundaries**: Separate **Transport/UI** (HTTP handlers, CLI, components) → **Usecase / Business Logic** → **Data / Infra** (SQL, external APIs). Never put raw SQL in HTTP handlers or domain rules inside UI components.
|
|
13
|
+
- **Rule of Three**: Prefer small, clear duplication over premature wrong abstractions; extract shared helpers only after a pattern repeats ≥3 times with identical intent.
|
|
14
|
+
- **Explicit Error Handling**: Never silently swallow errors; wrap errors with context and clearly distinguish client/domain errors (4xx) from infrastructure failures (5xx).
|
|
15
|
+
- **Readability First**: Use intention-revealing names, shallow nesting via early returns, and small single-purpose functions.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Database Performance & Lock-Safe Migrations (On-Demand)
|
|
2
|
+
|
|
3
|
+
Consult this guide when writing queries, changing schemas, or reviewing DB changes (`/spec`, `/review`).
|
|
4
|
+
|
|
5
|
+
## 1. Query Performance
|
|
6
|
+
- Run **`EXPLAIN ANALYZE`** on new or non-trivial queries before shipping to catch full-table scans early.
|
|
7
|
+
- Eliminate **N+1 queries** using batched `IN` queries, joins, or data loaders.
|
|
8
|
+
- Enforce bounded `LIMIT` / cursor pagination on every list or export endpoint (never unbounded `SELECT *`).
|
|
9
|
+
|
|
10
|
+
## 2. Lock-Safe Production Migrations
|
|
11
|
+
- Create indexes non-blocking (e.g., PostgreSQL `CREATE INDEX CONCURRENTLY`) so live writes are not blocked.
|
|
12
|
+
- Set explicit `lock_timeout` and `statement_timeout` on DDL migrations; fail fast instead of queuing production traffic.
|
|
13
|
+
- Never run heavy full-table backfills inside a single migration transaction; batch backfills separately and follow **Expand & Contract**.
|
|
14
|
+
|
|
15
|
+
## 3. Connection Pooling & Transactions
|
|
16
|
+
- Configure explicit pool limits (`max_open`, `max_idle`, `conn_max_lifetime`) and query timeouts.
|
|
17
|
+
- Keep DB transactions short: **NEVER** make external HTTP/RPC calls while holding a DB transaction open.
|
|
18
|
+
|
|
19
|
+
## 4. Backups & Restore Drills
|
|
20
|
+
- Maintain automated daily backups to isolated storage and run periodic **restore drills in Staging** to verify RPO/RTO.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Big Tech Developer Habits (On-Demand)
|
|
2
|
+
|
|
3
|
+
Engineering habits that keep velocity high, incidents rare, and codebases lean for both humans and AI agents.
|
|
4
|
+
|
|
5
|
+
## 1. Observability as Part of "Done"
|
|
6
|
+
- A feature is not done without **structured JSON logs** (`request_id`/`trace_id`), **1 success metric**, and **1 failure alert** (e.g. error rate >1% over 5m).
|
|
7
|
+
- Instrument critical paths before launch so issues are caught by alerts, not user reports.
|
|
8
|
+
|
|
9
|
+
## 2. Blameless Post-Mortems → Automated Guardrails
|
|
10
|
+
- After any production incident, ask *"why did the system allow this failure?"* rather than blaming individuals.
|
|
11
|
+
- Every post-mortem must produce at least **1 permanent automated guardrail**: a regression test, linter rule, DB constraint, or alert.
|
|
12
|
+
|
|
13
|
+
## 3. Delete Code & Feature Flag Hygiene
|
|
14
|
+
- Actively delete dead code, unused dependencies, and expired feature flags after rollout.
|
|
15
|
+
- Smaller, cleaner codebases have fewer bugs and consume far fewer AI agent tokens.
|
|
16
|
+
|
|
17
|
+
## 4. 15–20% Tech Debt Budget
|
|
18
|
+
- Reserve ~15–20% of sprint capacity for slow queries, flaky tests, dependency upgrades, and targeted refactors.
|
|
19
|
+
- Continuous small paydowns prevent risky, multi-month full rewrites.
|
|
20
|
+
|
|
21
|
+
## 5. Small PRs & High-Signal Reviews
|
|
22
|
+
- Keep PRs focused (`1 Issue = 1 PR`, ideally under ~300–400 changed lines).
|
|
23
|
+
- Explain **why** in the PR description, verify locally first, and never mix refactors with urgent fixes.
|
|
24
|
+
|
|
25
|
+
## 6. Definition of Done (DoD)
|
|
26
|
+
- [ ] Static checks, unit/integration tests, and critical E2E checks pass
|
|
27
|
+
- [ ] Peer reviewed (`/review`) with no unresolved P0/P1 findings
|
|
28
|
+
- [ ] Verified in Staging/Preview with logs & metrics clean
|
|
29
|
+
- [ ] Docs / ADR updated if contracts, schemas, or architecture changed
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Incident Response & Severity Guide (On-Demand)
|
|
2
|
+
|
|
3
|
+
Consult this guide during production outages, hotfixes, and post-mortems.
|
|
4
|
+
|
|
5
|
+
## 1. Severity Classification
|
|
6
|
+
- **SEV1 (Critical)**: full outage, data loss, or active security breach → immediate all-hands response, mitigate/rollback first.
|
|
7
|
+
- **SEV2 (Major)**: core feature degraded or elevated 5xx error rate → urgent response, mitigate or patch same day.
|
|
8
|
+
- **SEV3 (Minor)**: partial/non-critical impact with workaround → schedule normal `fix/` PR.
|
|
9
|
+
- **SEV4 (Low)**: cosmetic or minor annoyance → backlog.
|
|
10
|
+
|
|
11
|
+
## 2. First 5 Minutes Rule: Mitigate First, Investigate Second
|
|
12
|
+
1. Confirm blast radius via metrics/logs (5xx rate, latency, recent deploy/config change).
|
|
13
|
+
2. Restore service immediately: **rollback** immutable image tag, disable the **Feature Flag**, or shed/shift traffic before deep debugging.
|
|
14
|
+
3. Never run ad-hoc destructive commands or unreviewed schema drops in Production.
|
|
15
|
+
|
|
16
|
+
## 3. Team Status Communication Template
|
|
17
|
+
```markdown
|
|
18
|
+
- **Incident**: [SEV-X] <short summary>
|
|
19
|
+
- **Impact**: <who/what is affected>
|
|
20
|
+
- **Current Action**: <e.g., rolling back v1.4.2 -> v1.4.1>
|
|
21
|
+
- **Next Update**: <ETA, e.g., in 15 minutes>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 4. Post-Incident (Within 48 Hours)
|
|
25
|
+
Write a short **blameless post-mortem** (*Timeline, Root Cause, Detection Gap*) and create **at least 1 automated guardrail** (regression test, alert, or DB constraint) so the failure cannot repeat.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Modular Monolith & Microservices Guide (On-Demand)
|
|
2
|
+
|
|
3
|
+
Consult this guide when designing system boundaries (`/spec`, `/adr`) or evolving multi-service architectures.
|
|
4
|
+
|
|
5
|
+
## Part 1 — Modular Monolith (Recommended Default)
|
|
6
|
+
Start here unless you have a proven reason to distribute. You get ACID transactions, zero network hops, and simple deploys while keeping code cleanly decoupled:
|
|
7
|
+
- **Organize by Domain Module**, not giant technical folders (e.g. `modules/billing/`, `modules/auth/`, `modules/notifications/`).
|
|
8
|
+
- **Enforce Strict Module Boundaries**: Module A calls Module B **only** through Module B's public facade/interface (enforce via Go `internal/`, TypeScript package exports, or lint boundary rules). Never import another module's internal models or helpers directly.
|
|
9
|
+
- **Logical Data Ownership**: Even in one database, each module owns its tables. Avoid cross-module direct writes or tangled foreign-key joins across domain boundaries.
|
|
10
|
+
- **Simple Async First**: Use in-process workers or a DB-backed job queue before introducing dedicated message brokers.
|
|
11
|
+
- **When to Extract a Microservice**: Extract only for proven bottlenecks — independent scaling needs, independent team/release cadence, strict fault/security isolation, or a different runtime/language requirement.
|
|
12
|
+
|
|
13
|
+
## Part 2 — Microservices & Distributed Systems
|
|
14
|
+
Once a service is split across network boundaries, enforce these non-negotiable rules:
|
|
15
|
+
- **Database-per-Service**: Service B must NEVER query Service A's database tables directly; communicate only via versioned APIs or events.
|
|
16
|
+
- **Contract-First & Additive-Only Evolution**: Evolve OpenAPI, Protobuf, and event schemas additively (optional fields first, dual-support, deprecate, remove only after consumers migrate).
|
|
17
|
+
- **Transactional Outbox Pattern**: Avoid dual-write bugs (DB commit succeeds, broker publish fails). Write domain state + outbox event in the **same DB transaction**, then relay asynchronously.
|
|
18
|
+
- **Distributed Tracing**: Propagate `X-Request-ID` / W3C `traceparent` from edge/gateway through every downstream call and structured log.
|
|
19
|
+
- **Saga / Compensating Actions**: Replace distributed 2PC transactions with idempotent step-by-step workflows and explicit compensating actions on partial failure.
|
|
20
|
+
- **Resilience Defaults**: Enforce explicit timeouts, bounded retries with exponential backoff + jitter, and circuit breakers on every inter-service call.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Universal Quality Gates, API QA & Stress Testing (On-Demand)
|
|
2
|
+
|
|
3
|
+
Consult this reference during `/qa`, `/review`, and `/ship`.
|
|
4
|
+
|
|
5
|
+
## 1. Auto-Detect Execution Order
|
|
6
|
+
1. **Repo Scripts First**: Run existing `Makefile`, `Taskfile.yml`, `package.json`, or `.pre-commit-config.yaml` targets so local checks match CI.
|
|
7
|
+
2. **Stack Auto-Detection**: Otherwise detect manifests below and run all 4 gates: **Formatter**, **Lint & Typecheck**, **Vulnerability Audit**, and **Secret Scan**.
|
|
8
|
+
3. **Honest Reporting & Token Discipline**: If a tool is not installed locally, mark it `SKIPPED (not installed)` — never fake `PASS`. Pipe noisy logs through `| tail -n 50`.
|
|
9
|
+
|
|
10
|
+
## 2. Multi-Language Quality Gates
|
|
11
|
+
|
|
12
|
+
| Stack (Manifest) | Formatter | Lint & Typecheck | Vulncheck & Security |
|
|
13
|
+
|---|---|---|---|
|
|
14
|
+
| **Go** (`go.mod`) | `gofmt -l .` | `golangci-lint run`, `go vet ./...` | `govulncheck ./...` |
|
|
15
|
+
| **TS / JS** (`package.json`) | `prettier --check` / `biome check` | `eslint` / `biome`, `tsc --noEmit` | `npm audit --audit-level=high` (`pnpm`/`bun`) |
|
|
16
|
+
| **Python** (`pyproject.toml`) | `ruff format --check` | `ruff check`, `mypy` / `pyright` | `pip-audit`, `bandit` |
|
|
17
|
+
| **Rust** (`Cargo.toml`) | `cargo fmt --check` | `cargo clippy -- -D warnings` | `cargo audit` |
|
|
18
|
+
| **Java / Kotlin** (`pom.xml` / `build.gradle*`) | `spotlessCheck` | `checkstyle` / `ktlint` / `spotbugs` | `trivy fs .` / OWASP dep-check |
|
|
19
|
+
| **PHP** (`composer.json`) | `pint --test` / `php-cs-fixer` | `phpstan` / `psalm` | `composer audit` |
|
|
20
|
+
| **Infra / Universal** (`Dockerfile`, `*.sh`, `*.tf`) | `terraform fmt -check` | `hadolint`, `shellcheck` | `gitleaks detect`, `trivy fs .` |
|
|
21
|
+
|
|
22
|
+
## 3. API QA Checklist (Every API Change)
|
|
23
|
+
- **Validation & Negative Cases**: invalid payloads, boundary values, missing required fields return clean `400`/`422`.
|
|
24
|
+
- **AuthN & AuthZ / Tenant Isolation**: unauthenticated requests return `401`; cross-tenant or unauthorized role access returns `403`.
|
|
25
|
+
- **Idempotency**: duplicate `POST`/mutation requests with the same idempotency key produce a single safe side effect.
|
|
26
|
+
- **Pagination & Bounds**: list endpoints enforce `limit`/`page` caps (no unbounded `SELECT *` dumps).
|
|
27
|
+
- **Contract Alignment**: verify request/response shapes match OpenAPI / Protobuf / Pact specs.
|
|
28
|
+
|
|
29
|
+
## 4. Performance & Stress Testing (Staging Only — `k6`, `Locust`, `Vegeta`)
|
|
30
|
+
Run for high-traffic endpoints, batch jobs, or heavy DB changes — **never directly against Production** without explicit approval:
|
|
31
|
+
- **Smoke**: 1–5 VUs to verify test script and basic latency.
|
|
32
|
+
- **Load**: expected peak traffic vs SLO thresholds (e.g. `p95 < 200ms`, `error rate < 0.1%`).
|
|
33
|
+
- **Stress**: ramp beyond peak capacity to find breaking points and verify rate limits / autoscaling.
|
|
34
|
+
- **Spike**: sudden traffic bursts (cron jobs, webhooks, flash events).
|
|
35
|
+
- **Soak**: sustained load over hours to catch memory or connection-pool leaks.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Security & Multi-Tenant Checklist (On-Demand)
|
|
2
|
+
|
|
3
|
+
Consult this checklist when touching authentication, authorization, payments, or external inputs (`/spec`, `/review`).
|
|
4
|
+
|
|
5
|
+
## 1. AuthN / AuthZ & Multi-Tenant Isolation
|
|
6
|
+
- Enforce **server-side default-deny** RBAC/ABAC on every endpoint and mutation — never trust client-supplied role or tenant IDs.
|
|
7
|
+
- Scope every DB query (`WHERE tenant_id = ?`) and ownership check to prevent **IDOR** and cross-tenant data leaks.
|
|
8
|
+
|
|
9
|
+
## 2. Session & Token Hygiene
|
|
10
|
+
- Use short-lived access tokens with **refresh token rotation**; revoke sessions on logout, password reset, or role downgrade.
|
|
11
|
+
- Store browser session tokens in `HttpOnly`, `Secure`, `SameSite` cookies.
|
|
12
|
+
|
|
13
|
+
## 3. OWASP & Boundary Protection
|
|
14
|
+
- Use **parameterized queries only** (never string-concatenated SQL/shell commands).
|
|
15
|
+
- Validate/sanitize all external inputs at system boundaries and enforce **SSRF allowlists** on any server-side outbound URLs.
|
|
16
|
+
- Configure strict CORS, CSRF protection for cookie-auth routes, and **rate limiting** on auth/public endpoints.
|
|
17
|
+
|
|
18
|
+
## 4. PII Masking & Immutable Audit Trail
|
|
19
|
+
- Never log passwords, tokens, API keys, or raw PII (mask or omit sensitive fields).
|
|
20
|
+
- Emit an **immutable audit log** (*actor, action, target, timestamp, before → after*) for sensitive admin, billing, or permission changes.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Compact SDLC & Token-Saving Rules (Local LLM Edition)
|
|
2
|
+
|
|
3
|
+
1. **Scope**: Work on 1 task / 1 issue per session. If context grows large, write a <40-line summary to `.claude/HANDOFF.md` and start a fresh session.
|
|
4
|
+
2. **Read Sparingly**: For files >200 lines, search with grep/ripgrep first and read only the needed line range. Never dump whole directories or binary/image files.
|
|
5
|
+
3. **Bounded Commands**: Run targeted tests only (never full suites repeatedly) and pipe noisy logs through `| tail -n 50`.
|
|
6
|
+
4. **Frontend 5 States**: Every UI task must handle Default, Loading, Empty, Error, and Responsive/A11y.
|
|
7
|
+
5. **Bugs & Hotfixes**: Reproduce with a failing test first. Production hotfixes use minimal diffs only (no refactors).
|
|
8
|
+
6. **Safety**: Never run destructive commands (`kubectl apply`, `helm upgrade`, `DROP/ALTER`) directly against production. All prod changes go via Git PR -> CI -> CD.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
## What Changed
|
|
2
|
+
-
|
|
3
|
+
|
|
4
|
+
## How Verified
|
|
5
|
+
- [ ] Targeted unit/integration tests pass
|
|
6
|
+
|
|
7
|
+
## Checklist
|
|
8
|
+
- [ ] Focused PR (1 issue = 1 PR)
|
|
9
|
+
- [ ] Docs / ADR updated if API contract, schema, or architecture changed
|
|
10
|
+
- [ ] No secrets or local handoff artifacts committed
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Project Agent Instructions
|
|
2
|
+
|
|
3
|
+
Keep this file concise (<4 KB). Store deep docs in `docs/` (see `docs/INDEX.md`) and read on-demand.
|
|
4
|
+
|
|
5
|
+
## Stack & Commands
|
|
6
|
+
- **Build**: `<fill in>`
|
|
7
|
+
- **Test (targeted)**: `<fill in>`
|
|
8
|
+
- **Lint / Typecheck**: `<fill in>`
|
|
9
|
+
|
|
10
|
+
## Workflow & Token Discipline
|
|
11
|
+
- Follow `sdlc-workflow` (`1 Issue = 1 PR = 1 Session`).
|
|
12
|
+
- For files >200 lines, search symbols first and read targeted line ranges.
|
|
13
|
+
- Bound noisy command output (`| tail -n 50`) and run targeted tests.
|
|
14
|
+
- Save short session handoffs to `.claude/HANDOFF.md` (<60 lines) before clearing context.
|
|
15
|
+
- Never run destructive commands directly against production; all prod changes go via PR -> CI -> CD.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Documentation Index
|
|
2
|
+
|
|
3
|
+
Keep this index to 1 line per document so AI agents and humans can load only what is needed on-demand.
|
|
4
|
+
|
|
5
|
+
- [Architecture Decision Records](./adr/TEMPLATE.md) — Short records of key technical decisions
|
|
6
|
+
- `plans/` — Active multi-session feature specs and task breakdowns
|
|
7
|
+
- `runbooks/` — Deployment, rollback, and incident response guides
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# ADR-NNN: Title
|
|
2
|
+
|
|
3
|
+
**Status**: Proposed | Accepted | Superseded (YYYY-MM-DD)
|
|
4
|
+
|
|
5
|
+
## Context
|
|
6
|
+
What problem or constraint requires a decision? (3–5 lines)
|
|
7
|
+
|
|
8
|
+
## Decision
|
|
9
|
+
What did we choose? (2–4 lines)
|
|
10
|
+
|
|
11
|
+
## Rationale
|
|
12
|
+
Why this option over alternatives? (3–5 bullets)
|
|
13
|
+
|
|
14
|
+
## Consequences
|
|
15
|
+
- Positive outcomes
|
|
16
|
+
- Trade-offs or follow-up work
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Keep planning artifacts out of gitignore collision; tracked intentionally
|