hero-vibe-kit 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/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/bin/hero-vibe-kit.js +62 -0
- package/package.json +35 -0
- package/presets/enterprise.json +6 -0
- package/presets/small-team.json +6 -0
- package/presets/solo.json +6 -0
- package/skills.manifest.json +39 -0
- package/src/detect.cjs +42 -0
- package/src/doctor.cjs +74 -0
- package/src/init.cjs +95 -0
- package/src/integrations.cjs +89 -0
- package/src/links.cjs +37 -0
- package/src/merge.cjs +61 -0
- package/src/render.cjs +27 -0
- package/src/update.cjs +59 -0
- package/src/util.cjs +56 -0
- package/templates/AGENTS.md.tmpl +9 -0
- package/templates/CLAUDE.md.tmpl +11 -0
- package/templates/common/.claude/hooks/git-guard.cjs +55 -0
- package/templates/common/.claude/hooks/stop-reminder.cjs +34 -0
- package/templates/common/.claude/settings.json +25 -0
- package/templates/docs/en/ACTIVE_STATE.md +28 -0
- package/templates/docs/en/AGENCY_WORKFLOW.md +126 -0
- package/templates/docs/en/BRANCHING.md +44 -0
- package/templates/docs/en/COMMUNICATION_PROTOCOL.md +59 -0
- package/templates/docs/en/DEFINITION_OF_DONE.md +60 -0
- package/templates/docs/en/INTERACTION_PATTERNS.md +58 -0
- package/templates/docs/en/PERFORMANCE_STANDARDS.md +31 -0
- package/templates/docs/en/SECURITY_STANDARDS.md +37 -0
- package/templates/docs/en/TEAM_ROSTER.md +35 -0
- package/templates/docs/en/templates/PRD_AI_FEATURE.md +85 -0
- package/templates/docs/vi/ACTIVE_STATE.md +28 -0
- package/templates/docs/vi/AGENCY_WORKFLOW.md +126 -0
- package/templates/docs/vi/BRANCHING.md +44 -0
- package/templates/docs/vi/COMMUNICATION_PROTOCOL.md +59 -0
- package/templates/docs/vi/DEFINITION_OF_DONE.md +60 -0
- package/templates/docs/vi/INTERACTION_PATTERNS.md +58 -0
- package/templates/docs/vi/PERFORMANCE_STANDARDS.md +31 -0
- package/templates/docs/vi/SECURITY_STANDARDS.md +37 -0
- package/templates/docs/vi/TEAM_ROSTER.md +35 -0
- package/templates/docs/vi/templates/PRD_AI_FEATURE.md +85 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Branching & Commit Convention
|
|
2
|
+
|
|
3
|
+
> Model: **{{BRANCHING_MODEL}}** for a {{TEAM_SIZE}} team. `main` is always deployable.
|
|
4
|
+
|
|
5
|
+
## Branches
|
|
6
|
+
- **`main`** — protected. NO direct commits/pushes. All changes land via a **Merge/Pull Request (MR/PR)**.
|
|
7
|
+
- Short-lived working branches, created from `main`, named `<type>/<short-kebab-description>`:
|
|
8
|
+
|
|
9
|
+
| Prefix | Use for | Task type (router) |
|
|
10
|
+
|--------|---------|--------------------|
|
|
11
|
+
| `feat/` | new feature | #7 |
|
|
12
|
+
| `fix/` | bug fix | #3 |
|
|
13
|
+
| `change/` | change existing feature logic | #5 |
|
|
14
|
+
| `refactor/` | cleanup, no behavior change | #6 |
|
|
15
|
+
| `chore/` | build, deps, config | #2 |
|
|
16
|
+
| `docs/` | docs only | #2 |
|
|
17
|
+
| `hotfix/` | urgent prod patch (off `main`) | #4 |
|
|
18
|
+
| `spike/` | research/POC (throwaway, code not merged) | #8 |
|
|
19
|
+
|
|
20
|
+
Examples: `feat/user-login`, `fix/null-cart-total`, `change/discount-rounding`.
|
|
21
|
+
|
|
22
|
+
## Merge/Pull Request
|
|
23
|
+
- **At least 1 reviewer** approval required before merge.
|
|
24
|
+
- Must meet the [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md) of its path (CI green).
|
|
25
|
+
- **Squash merge** into `main` for a clean history (1 branch = 1 meaningful commit).
|
|
26
|
+
- Delete the branch after merge.
|
|
27
|
+
- The MR description states **what + why**, links PRD/TDD for Standard/Full.
|
|
28
|
+
|
|
29
|
+
## Commits — Conventional Commits
|
|
30
|
+
Format: `<type>(<scope>): <description>` — type matches the branch prefix: `feat` `fix` `refactor` `chore` `docs` `test` `perf`.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
feat(auth): add email login
|
|
34
|
+
fix(cart): handle null total when cart is empty
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- BREAKING CHANGE: add `!` after the type (`feat!:`) or a `BREAKING CHANGE:` footer.
|
|
38
|
+
- Do NOT use `--no-verify` / `--no-gpg-sign` unless the user explicitly asks (the hook will block it).
|
|
39
|
+
|
|
40
|
+
## Hotfix & backport
|
|
41
|
+
1. Create `hotfix/<...>` from `main`.
|
|
42
|
+
2. Minimal patch + a reproducing test → fast MR (still reviewed) → merge into `main`.
|
|
43
|
+
3. **Backport**: cherry-pick/merge the change into the open development branch so it isn't lost when that branch merges later.
|
|
44
|
+
4. Log the incident for a post-mortem (Phase 5 retro).
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Communication Protocol — Human ↔ AI
|
|
2
|
+
|
|
3
|
+
> The communication contract between the **human** (Product Owner / Dev) and the **AI agents** on this project. Applies to **every interaction**, especially when **clarifying requirements** (Phase 1). A mandatory part of [AGENCY_WORKFLOW.md](./AGENCY_WORKFLOW.md).
|
|
4
|
+
>
|
|
5
|
+
> Because this product *is* an AI assistant, the quality of requirements clarification drives the quality of the product — this protocol exists to eliminate silent misunderstandings.
|
|
6
|
+
|
|
7
|
+
## 1. Language & style
|
|
8
|
+
- The team's working language is the default when talking to the user; **keep technical terms in English** (API, endpoint, prompt, token…).
|
|
9
|
+
- Concise and direct, no rambling. Present important options with a clear recommendation.
|
|
10
|
+
- Cite `file:line` when discussing code.
|
|
11
|
+
|
|
12
|
+
## 2. Core principles
|
|
13
|
+
1. **No silent assumptions** — Never fabricate missing information. When something is missing, either **ASK**, or state an **explicit assumption** labeled `ASSUMPTION:` so the user can easily reject it.
|
|
14
|
+
2. **Layered certainty** — Clearly separate:
|
|
15
|
+
- ✅ **Certain** (read the code/docs, have evidence)
|
|
16
|
+
- 🤔 **Inferred** (reasonable inference, not verified)
|
|
17
|
+
- ❓ **Needs confirmation** (depends on a user decision)
|
|
18
|
+
3. **Truth over agreement** — The AI pushes back when a request is contradictory/risky; it doesn't just agree to be agreeable. (The reverse direction: when receiving feedback, use the `receiving-code-review` skill — verify technically, no performative agreement.)
|
|
19
|
+
4. **Evidence before assertions** — Never declare "done/passing" without running a verification command (see `verification-before-completion`).
|
|
20
|
+
|
|
21
|
+
## 3. Requirements clarification protocol
|
|
22
|
+
### 3.1. Question classification
|
|
23
|
+
| Type | Definition | Handling |
|
|
24
|
+
|------|-----------|----------|
|
|
25
|
+
| **Blocking** | Without an answer you CANNOT proceed correctly (e.g. scope, audience, hard constraints) | Must ask & wait for the user |
|
|
26
|
+
| **Non-blocking** | Has a reasonable default | The AI **decides via the default**, stating the `ASSUMPTION:` used so the user can adjust later |
|
|
27
|
+
|
|
28
|
+
> Goal: don't block progress on things that have a reasonable default; only block on what genuinely needs a human decision.
|
|
29
|
+
|
|
30
|
+
### 3.2. How to ask
|
|
31
|
+
- **Independent questions** → batch them via **`AskUserQuestion`** (up to ~4, each with options + a recommendation).
|
|
32
|
+
- **Exploratory / dependent questions** → ask **sequentially, one at a time** (per the `brainstorming` skill) so later questions build on earlier ones.
|
|
33
|
+
- Prefer multiple-choice over open-ended when possible.
|
|
34
|
+
|
|
35
|
+
### 3.3. End every clarification round
|
|
36
|
+
Each round closes with 3 items:
|
|
37
|
+
1. **Summary of current understanding** (a short paragraph — for the user to spot mistakes).
|
|
38
|
+
2. **Open questions** (which blocking ones are unanswered).
|
|
39
|
+
3. **Assumptions in effect** (the assumptions register — the list of `ASSUMPTION:`s currently in use).
|
|
40
|
+
|
|
41
|
+
## 4. Confirmation, sign-off & repairing misunderstandings
|
|
42
|
+
- **Gate = real Plan Mode**: lock the PRD/TDD via `EnterPlanMode → ExitPlanMode`, not a prose "awaiting approval".
|
|
43
|
+
- **Loop repair on misunderstanding**: when the user corrects something → the AI **restates the NEW understanding in its own words** and **waits for confirmation** before continuing. No silent "re-understanding".
|
|
44
|
+
- Once the user approves, treat it as a **commitment** — to change it, reopen the gate, don't silently change direction.
|
|
45
|
+
|
|
46
|
+
## 5. Decision log & Assumptions register
|
|
47
|
+
Recorded per feature in the PRD (see template):
|
|
48
|
+
- **Decision Log**: `| Date | Question/Issue | Decision | Decided by | Rationale |` — so later you know "why we chose that back then".
|
|
49
|
+
- **Assumptions Register**: the list of assumptions in effect + status (`pending` / `confirmed` / `rejected`).
|
|
50
|
+
|
|
51
|
+
## 6. Rules for sub-agents (multi-agent)
|
|
52
|
+
- **Sub-agents do NOT talk to the user directly.** If information is missing / a human decision is needed → **report to the Main Agent**, which aggregates and then asks the user. Avoids multiple agents asking conflicting questions.
|
|
53
|
+
- The Main Agent is the **single point of contact** with the user.
|
|
54
|
+
- Prompts handed to sub-agents must be **self-contained** (see [TEAM_ROSTER.md](./TEAM_ROSTER.md)) — including the relevant assumptions/decisions already settled with the user.
|
|
55
|
+
|
|
56
|
+
## 7. Related
|
|
57
|
+
- [AGENCY_WORKFLOW.md](./AGENCY_WORKFLOW.md) — Phase 1 applies this protocol.
|
|
58
|
+
- [templates/PRD_AI_FEATURE.md](./templates/PRD_AI_FEATURE.md) — dimensions to clarify for AI features.
|
|
59
|
+
- [INTERACTION_PATTERNS.md](./INTERACTION_PATTERNS.md) — how the *product* talks to end-users (distinct from this doc: this is human↔AI during development).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Definition of Done (DoD)
|
|
2
|
+
|
|
3
|
+
> **Measurable** completion criteria. A change is "done" only when it meets the DoD for its path. The path is decided by [AGENCY_WORKFLOW.md §1](./AGENCY_WORKFLOW.md#1-task-classification--workflow-router).
|
|
4
|
+
|
|
5
|
+
## ⚙️ Placeholders to fill when the tech stack is chosen
|
|
6
|
+
Stack not decided yet — fill these in the first PRD/TDD, then update this file:
|
|
7
|
+
|
|
8
|
+
| Variable | Value | Example |
|
|
9
|
+
|----------|-------|---------|
|
|
10
|
+
| `<TEST_CMD>` | test command | `npm test` / `pytest` |
|
|
11
|
+
| `<LINT_CMD>` | lint + format check | `npm run lint` / `ruff check .` |
|
|
12
|
+
| `<BUILD_CMD>` | build command | `npm run build` / `—` |
|
|
13
|
+
| `<COVERAGE_MIN>` | minimum coverage threshold | `80%` |
|
|
14
|
+
| `<TYPECHECK_CMD>` | type check (if any) | `tsc --noEmit` / `mypy .` |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Checklist by path
|
|
19
|
+
|
|
20
|
+
### Read-only (Q&A / Explain)
|
|
21
|
+
- [ ] Answers the core of the question.
|
|
22
|
+
- [ ] Cites `file:line` for every claim about code.
|
|
23
|
+
- [ ] No branch / no commit / no file edits.
|
|
24
|
+
|
|
25
|
+
### Fast path (Chore / Docs / Config / Small bugfix / Hotfix)
|
|
26
|
+
- [ ] Correct branch prefix ([BRANCHING.md](./BRANCHING.md)).
|
|
27
|
+
- [ ] `<TEST_CMD>` green · `<LINT_CMD>` green · `<BUILD_CMD>` green.
|
|
28
|
+
- [ ] **Bugfix/Hotfix:** a test reproducing the bug went RED → GREEN; regression suite still passes.
|
|
29
|
+
- [ ] **Chore/Docs:** no runtime behavior change.
|
|
30
|
+
- [ ] Conventional Commits; MR briefly describes *what + why*.
|
|
31
|
+
- [ ] Ran `gitnexus_detect_changes` (when code exists) — scope as expected.
|
|
32
|
+
- [ ] **Security (light):** no new secret committed (see [SECURITY_STANDARDS.md](./SECURITY_STANDARDS.md) §5). **Performance (light):** no obvious regression / no new N+1 ([PERFORMANCE_STANDARDS.md](./PERFORMANCE_STANDARDS.md) §4).
|
|
33
|
+
|
|
34
|
+
### Standard path (Change logic / Refactor)
|
|
35
|
+
Includes all of Fast path, plus:
|
|
36
|
+
- [ ] Passed the **Gate** (Plan Mode) and the user approved the approach.
|
|
37
|
+
- [ ] `gitnexus_impact` (upstream) ran & **blast radius + risk level reported**; HIGH/CRITICAL risk accepted by the user.
|
|
38
|
+
- [ ] `<TYPECHECK_CMD>` green (if applicable).
|
|
39
|
+
- [ ] **Refactor:** the same test suite passes before & after (behavior unchanged); renames use `gitnexus_rename`, not manual find-replace.
|
|
40
|
+
- [ ] **Change logic:** old regression tests still green + new tests for new behavior.
|
|
41
|
+
- [ ] QA sub-agent reviewed (`code-review`); `security-review` if touching a sensitive surface.
|
|
42
|
+
- [ ] **Security (Standard):** input validation for touched code + authz checks if touched ([SECURITY_STANDARDS.md](./SECURITY_STANDARDS.md) §5). **Performance (Standard):** before/after bench for hot paths; (AI) prompt caching preserved ([PERFORMANCE_STANDARDS.md](./PERFORMANCE_STANDARDS.md) §4).
|
|
43
|
+
|
|
44
|
+
### Full path (New feature)
|
|
45
|
+
Includes all of Standard path, plus:
|
|
46
|
+
- [ ] **PRD** approved (Gate 1) and linked in ACTIVE_STATE.
|
|
47
|
+
- [ ] **TDD** approved (Gate 2): includes a light threat model + API/interface contract.
|
|
48
|
+
- [ ] Coverage ≥ `<COVERAGE_MIN>` for new code.
|
|
49
|
+
- [ ] Meets all acceptance criteria in the PRD.
|
|
50
|
+
- [ ] `security-review` ran, no unresolved new findings.
|
|
51
|
+
- [ ] **Security standards (Full):** meets [SECURITY_STANDARDS.md](./SECURITY_STANDARDS.md) §5; AI features checked against OWASP LLM Top 10 (§2) including abuse cases.
|
|
52
|
+
- [ ] **Performance standards (Full):** meets the [PERFORMANCE_STANDARDS.md](./PERFORMANCE_STANDARDS.md) §1 budget; AI features meet the token/latency ceiling §2; load measurement exists for the main flow.
|
|
53
|
+
- [ ] **Handover:** CLAUDE.md updated with new architectural decisions (if any); 3-line retro recorded; Serena memory updated (pointers); task `completed` + ACTIVE_STATE updated.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Invariants (all paths)
|
|
58
|
+
1. **Never claim "done/passing" without running a verification command** — evidence before assertions (`verification-before-completion`).
|
|
59
|
+
2. **Tests must actually test behavior**, not empty/fully-mocked tests just to pass.
|
|
60
|
+
3. **ACTIVE_STATE.md is updated** when work status changes.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Interaction Patterns — Assistant ↔ End-User (Product Layer)
|
|
2
|
+
|
|
3
|
+
> A library of **patterns for how the PRODUCT talks to end-users**. Distinct from [COMMUNICATION_PROTOCOL.md](./COMMUNICATION_PROTOCOL.md) (human↔AI during *development*) — this is how the *built assistant* talks to *end-users*.
|
|
4
|
+
>
|
|
5
|
+
> A **reusable asset**: each AI-feature PRD (§3, §5, §8 of the [template](./templates/PRD_AI_FEATURE.md)) references these patterns instead of redesigning from scratch. Specific thresholds/details (`<TBD>`) are locked per PRD.
|
|
6
|
+
|
|
7
|
+
## Foundational principles
|
|
8
|
+
1. **The user stays in control** — the assistant assists; it doesn't unilaterally make hard-to-reverse decisions for the user.
|
|
9
|
+
2. **Be transparent about limits** — say clearly when unsure, when it doesn't know, or when it can't do something; never fabricate.
|
|
10
|
+
3. **Error cost shapes behavior** — low-risk actions → just do them; high-risk/hard-to-reverse → confirm first.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## P1 — Clarification (clarifying intent)
|
|
15
|
+
- **When to ask back:** ambiguous intent, missing required parameters, or multiple interpretations leading to very different results.
|
|
16
|
+
- **When NOT to ask:** there's a safe/clear default → just do it and **state the assumption** ("I understood it as X, let me know if that's wrong").
|
|
17
|
+
- **How to ask:** one focused question, with 2–4 options if possible; don't torture the user with a chain of questions.
|
|
18
|
+
- **Threshold:** at most `<TBD>` questions before giving a best-effort attempt.
|
|
19
|
+
|
|
20
|
+
## P2 — Confirmation (confirm before acting)
|
|
21
|
+
- **Confirmation required** before actions that are: hard to reverse, affect data/money/other people, or go outward (send email, publish…).
|
|
22
|
+
- **Not needed** for read-only/non-destructive actions.
|
|
23
|
+
- State **what's about to happen + the consequence**, then ask for consent.
|
|
24
|
+
|
|
25
|
+
## P3 — Uncertainty / Low-confidence
|
|
26
|
+
- When unsure → **state the confidence level** + offer to verify, instead of asserting confidently.
|
|
27
|
+
- Cite sources/grounding when available. Distinguish "I know" vs "I'm inferring".
|
|
28
|
+
|
|
29
|
+
## P4 — Error & Graceful Degradation
|
|
30
|
+
- On error → explain **in the user's language** (don't swallow the error, don't dump a stack trace).
|
|
31
|
+
- Prefer **a partial result + naming what's missing** over a blank failure.
|
|
32
|
+
- Suggest the next step / how to retry.
|
|
33
|
+
|
|
34
|
+
## P5 — Refusal (safe refusal)
|
|
35
|
+
- Structure: **a concise refusal + reason + (if any) a valid alternative**.
|
|
36
|
+
- Keep a respectful, non-judgmental tone; don't reveal internal filtering details.
|
|
37
|
+
- Distinguish "not allowed" vs "can't do it" vs "needs more info".
|
|
38
|
+
|
|
39
|
+
## P6 — Handoff to Human
|
|
40
|
+
- When to escalate: out of scope, high risk, the user requests it, or repeated failure.
|
|
41
|
+
- Hand off with a **context summary** so the receiving human doesn't have to ask from scratch.
|
|
42
|
+
|
|
43
|
+
## P7 — Conversation Repair
|
|
44
|
+
- The user says "that's not it" → the assistant **briefly acknowledges, restates the new understanding, confirms**, then continues.
|
|
45
|
+
- Don't repeat the same wrong answer; don't get defensive.
|
|
46
|
+
|
|
47
|
+
## P8 — Memory & Privacy
|
|
48
|
+
- Be clear about **what the assistant remembers / doesn't**; give the user a way to view/delete it.
|
|
49
|
+
- Don't expose sensitive data in responses/logs; follow the PRD §5 PII policy.
|
|
50
|
+
|
|
51
|
+
## P9 — Tone & Consistency
|
|
52
|
+
- One consistent persona across features (locked in [TEAM_ROSTER.md](./TEAM_ROSTER.md) §3 / PRD §4).
|
|
53
|
+
- Concise by default; detailed when the user needs it.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## How to use
|
|
58
|
+
In an AI-feature PRD: §3 (ambiguity) points to **P1**; §5 (safety) points to **P5/P8**; §8 (fallback) points to **P4/P6/P7**; §4 (tone) points to **P9**. Each pattern gets the specific threshold/details for that feature.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Performance Standards
|
|
2
|
+
|
|
3
|
+
> A **measurable** performance budget for {{PROJECT_NAME}}. Part of [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md), considered at **Phase 2 (set the budget)** + **Phase 4 (verify)** in [AGENCY_WORKFLOW.md](./AGENCY_WORKFLOW.md).
|
|
4
|
+
>
|
|
5
|
+
> Fill the `<TBD>`s per product requirements when locked in the first PRD/TDD.
|
|
6
|
+
|
|
7
|
+
## 1. General budget (parameterized)
|
|
8
|
+
- **Latency**: API p95 ≤ `<TBD>` ms, p99 ≤ `<TBD>` ms.
|
|
9
|
+
- **Throughput**: ≥ `<TBD>` req/s at target load.
|
|
10
|
+
- **Size**: payload/response ≤ `<TBD>`; frontend bundle (if any) ≤ `<TBD>` KB.
|
|
11
|
+
- **Database**: no N+1; queries per request ≤ `<TBD>`; indexes for hot queries.
|
|
12
|
+
- **Memory/CPU**: no leaks; baseline ≤ `<TBD>`.
|
|
13
|
+
|
|
14
|
+
## 2. AI-specific (required for AI features)
|
|
15
|
+
> Cross-reference `templates/PRD_AI_FEATURE.md §9`.
|
|
16
|
+
- **Prompt caching — REQUIRED**: leverage Claude's caching for static prompt parts (system, grounding docs) to cut cost & latency. This is the biggest lever.
|
|
17
|
+
- **Model selection by task**: use the lightest sufficient model (Haiku → Sonnet → Opus); don't default to the strongest model for everything.
|
|
18
|
+
- **Token/cost ceiling**: a per-request token & cost ceiling `<TBD>`; alert on breach.
|
|
19
|
+
- **Streaming**: stream long responses to reduce perceived latency.
|
|
20
|
+
- **Context discipline**: load only the needed context; avoid stuffing whole documents into every turn.
|
|
21
|
+
- **Batching**: batch large non-realtime workloads.
|
|
22
|
+
|
|
23
|
+
## 3. Performance regression gate
|
|
24
|
+
- **`change/` + `refactor/` touching a hot path**: measure a **before & after bench**, don't regress more than `<TBD>`%.
|
|
25
|
+
- **Feature** (Full path): at least one load measurement/assessment for the critical flow before merge.
|
|
26
|
+
- **Observability**: track p95/p99, token/cost, error rate after going to prod (see PRD §10).
|
|
27
|
+
|
|
28
|
+
## 4. Checklist by path (feeds the DoD)
|
|
29
|
+
- **Fast path**: no obvious performance regression; no new N+1.
|
|
30
|
+
- **Standard path**: + before/after bench for code touching a hot path; + (AI) prompt caching preserved/applied.
|
|
31
|
+
- **Full path**: + meets the §1 budget; + (AI feature) meets the §2 token/latency ceiling; + a load measurement exists for the main flow.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Security Standards
|
|
2
|
+
|
|
3
|
+
> A **measurable** security baseline for {{PROJECT_NAME}}. It is the bar `security-review` (Phase 4) grades against and part of [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md). Shift-left: most of it is considered during **threat modeling in Phase 2** ([AGENCY_WORKFLOW.md](./AGENCY_WORKFLOW.md)).
|
|
4
|
+
>
|
|
5
|
+
> Fill the `<TBD>`s per your stack/compliance when locked in the first PRD/TDD.
|
|
6
|
+
|
|
7
|
+
## 1. General baseline (every project)
|
|
8
|
+
- **Secrets**: NEVER hardcode secrets/keys/API tokens in code or logs. Use env vars / a secret manager. `.env` must be in `.gitignore`. Enable secret-scanning (§4).
|
|
9
|
+
- **Dependency & supply-chain**: pin versions (lockfile); run `<AUDIT_CMD>` (e.g. `npm audit` / `pip-audit`); enable auto-updates (Dependabot/Renovate); only add dependencies from trusted sources.
|
|
10
|
+
- **Input validation & output encoding**: validate all external input (user, API, file); encode output by context (prevent XSS/SQLi/command injection). Use parameterized queries, no string concatenation.
|
|
11
|
+
- **AuthN/AuthZ**: explicit authentication; **least privilege** for every role/key/resource; check permissions server-side, never trust the client.
|
|
12
|
+
- **Transport & data at rest**: TLS for all traffic; encrypt sensitive data at rest where needed.
|
|
13
|
+
- **Logging**: log enough to investigate but **never leak secrets/PII**; don't print stack traces/internals to end-users.
|
|
14
|
+
- **Error handling**: user-facing errors don't reveal system details (paths, versions, queries…).
|
|
15
|
+
|
|
16
|
+
## 2. AI-specific — OWASP LLM Top 10 (required for AI features)
|
|
17
|
+
> Cross-reference `templates/PRD_AI_FEATURE.md §5`.
|
|
18
|
+
- **Prompt injection**: separate the **system prompt** from **untrusted content** (user input, fetched data, tool output). Do NOT blindly execute/follow instructions embedded in untrusted data.
|
|
19
|
+
- **Sensitive information disclosure**: don't let the model leak secrets/PII/other customers' data; filter output; minimize data put into context.
|
|
20
|
+
- **Excessive agency**: restrict **tool/agent permissions** (grant only the tools truly needed); hard-to-reverse actions require confirmation/human-in-the-loop (see [INTERACTION_PATTERNS.md](./INTERACTION_PATTERNS.md) P2/P6).
|
|
21
|
+
- **Insecure output handling**: treat model output as **untrusted data** — validate/sanitize before rendering HTML, executing code, or passing it downstream.
|
|
22
|
+
- **Guardrails & refusal**: a policy for refusing forbidden content (PRD §5); resist abuse/jailbreaks.
|
|
23
|
+
- **Model/plugin supply chain**: only use models/MCP/plugins from trusted sources; record versions.
|
|
24
|
+
|
|
25
|
+
## 3. Process security (partly enforced by hooks)
|
|
26
|
+
- `main` is protected; changes land via MR ([BRANCHING.md](./BRANCHING.md)). The `git-guard` hook blocks force-push, `commit --no-verify`, `reset --hard`.
|
|
27
|
+
- Don't bypass hooks/CI "to go faster".
|
|
28
|
+
|
|
29
|
+
## 4. Automated tools (optional — degrade if absent)
|
|
30
|
+
- **Secret scanning**: e.g. `gitleaks` (can run as a pre-commit hook to **block**). `<TBD: on/off>`
|
|
31
|
+
- **`<AUDIT_CMD>`** in CI / the `doctor` command.
|
|
32
|
+
- **SAST** (stack-dependent): `<TBD>`.
|
|
33
|
+
|
|
34
|
+
## 5. Checklist by path (feeds the DoD)
|
|
35
|
+
- **Fast path**: no new secret committed; `<AUDIT_CMD>` reports no new critical issues.
|
|
36
|
+
- **Standard path**: + input validation for touched code; + permission checks if touching authz.
|
|
37
|
+
- **Full path**: + the threat model (Phase 2) is addressed; + `security-review` passes; + (AI feature) all of §2 verified, including abuse cases.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Team Roster & Agent Personas
|
|
2
|
+
|
|
3
|
+
> Personas are **thinking lenses**, not mandatory ceremony for every task. The process & paths: see [AGENCY_WORKFLOW.md](./AGENCY_WORKFLOW.md) (SSOT).
|
|
4
|
+
|
|
5
|
+
## 1. Main Agent (Lead)
|
|
6
|
+
Holds the session, talks to the user, orchestrates sub-agents. Rotates hats:
|
|
7
|
+
- **BA** — `brainstorming`: clarify requirements, write the PRD, get sign-off (Gate 1).
|
|
8
|
+
- **System Architect** — `gitnexus_exploring` + `gitnexus_impact`: design, write the TDD, lock the API contract + threat model, split tasks (Gate 2).
|
|
9
|
+
- **Scrum Master** — manages [ACTIVE_STATE.md](./ACTIVE_STATE.md), updates CLAUDE.md & Serena memory.
|
|
10
|
+
|
|
11
|
+
## 2. Sub-agents (Dev / QA)
|
|
12
|
+
Spawned via the `Agent` tool when the work is large enough (Standard/Full path).
|
|
13
|
+
|
|
14
|
+
> ⚠️ **Sub-agents do NOT inherit the Main Agent's conversation, skills, or context.** So **every spawn prompt must be SELF-CONTAINED**, including:
|
|
15
|
+
> 1. Links to the specific **PRD/TDD** files to read.
|
|
16
|
+
> 2. Persona + **the skill names to invoke** (be explicit, e.g. "use the `test-driven-development` skill").
|
|
17
|
+
> 3. **Done criteria** (point to the matching path in [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md)).
|
|
18
|
+
> 4. The list of relevant files/areas + constraints (API contract).
|
|
19
|
+
|
|
20
|
+
| Role | Skills/Tools | Job |
|
|
21
|
+
|------|--------------|-----|
|
|
22
|
+
| **Frontend Dev** | the locked design direction (see §3), test-driven-development | Implement the UI per the TDD, follow the design system |
|
|
23
|
+
| **Backend Dev** | test-driven-development | Logic / API / DB schema, safe & efficient |
|
|
24
|
+
| **Code Reviewer** (`code-reviewer`) | code-review, simplify | Review diffs: correctness, security, cleanliness |
|
|
25
|
+
| **QA / Security** | security-review, systematic-debugging, verification-before-completion, verify | Break the code, find bugs, ensure execution flows are intact |
|
|
26
|
+
|
|
27
|
+
## 3. Design direction — PICK ONE
|
|
28
|
+
There are many design skills (`design-taste-frontend`, `minimalist-ui`, `industrial-brutalist-ui`, `high-end-visual-design`, `gpt-taste`, `brandkit`…). **Pick exactly ONE direction for {{PROJECT_NAME}}** (decided in the first PRD/TDD), define tokens/type scale/spacing once, then Frontend follows it.
|
|
29
|
+
- Chosen design direction: **`<TBD — fill when the first UI feature appears>`**
|
|
30
|
+
- Do NOT invoke multiple design skills at once within one feature → avoids inconsistent UI.
|
|
31
|
+
|
|
32
|
+
## 4. Delegation rules
|
|
33
|
+
1. **Don't write the bulk of the code in the main thread** if the work is large → delegate to sub-agents.
|
|
34
|
+
2. **Conditional parallelization**: only spawn FE & BE in parallel **after the API contract is locked in Phase 2**.
|
|
35
|
+
3. **Worktrees**: use `isolation: "worktree"` when multiple agents may edit overlapping files.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# PRD — <AI feature name>
|
|
2
|
+
|
|
3
|
+
> A PRD template **specifically for AI/assistant features**. Purpose: force the dimensions that deterministic software usually misses. Fill everything in; for unknowns write `ASSUMPTION:` or `<TBD>` (don't leave silent blanks). Follow [COMMUNICATION_PROTOCOL.md](../COMMUNICATION_PROTOCOL.md).
|
|
4
|
+
>
|
|
5
|
+
> Copy this file to `docs/specs/YYYY-MM-DD-<feature>.md` when starting Phase 1.
|
|
6
|
+
|
|
7
|
+
**Status:** Draft | In Review | Approved
|
|
8
|
+
**Date:** YYYY-MM-DD · **Product Owner:** · **Path (router):** Full / Standard
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. Context & goals
|
|
13
|
+
- **User problem:** <what pain does this feature solve?>
|
|
14
|
+
- **Measurable goal:** <e.g. reduce X% time, reach Y% correct answers>
|
|
15
|
+
- **Persona / audience:**
|
|
16
|
+
|
|
17
|
+
## 2. Assistant Intent & Scope ⭐
|
|
18
|
+
- **DOES (in-scope):** <what the assistant must be able to do>
|
|
19
|
+
- **DOES NOT (explicitly out-of-scope):** <boundaries — crucial against scope creep & unintended behavior>
|
|
20
|
+
- **Primary use cases (prioritized):**
|
|
21
|
+
|
|
22
|
+
## 3. Behavior under AMBIGUITY / missing info ⭐
|
|
23
|
+
> A core decision for an assistant. Reference [INTERACTION_PATTERNS.md](../INTERACTION_PATTERNS.md).
|
|
24
|
+
- When user intent is unclear → does the assistant **ask back / guess-then-state / refuse**? <pick & justify>
|
|
25
|
+
- **Confidence threshold** to act vs ask back: `<TBD>`
|
|
26
|
+
- Max questions before it must act: `<TBD>`
|
|
27
|
+
|
|
28
|
+
## 4. Tone & Persona
|
|
29
|
+
- Voice (formal/friendly/concise…):
|
|
30
|
+
- Things the assistant must **never** say/do stylistically:
|
|
31
|
+
- Supported languages:
|
|
32
|
+
|
|
33
|
+
## 5. Guardrails & Safety ⭐
|
|
34
|
+
> Follow [SECURITY_STANDARDS.md](../SECURITY_STANDARDS.md) — especially §2 (OWASP LLM Top 10).
|
|
35
|
+
- **Refusal policy:** which requests must be refused + how (see the Refusal pattern in INTERACTION_PATTERNS).
|
|
36
|
+
- **Sensitive data / PII:** what's collected, what's stored, how it's masked, which regulations.
|
|
37
|
+
- **Prompt injection / abuse:** defenses (separate system/user content, check output…).
|
|
38
|
+
- **Forbidden / restricted content:**
|
|
39
|
+
|
|
40
|
+
## 6. Definition of "CORRECT" (output is non-deterministic) ⭐
|
|
41
|
+
> You can't use a single `assertEquals` for AI output. You must define *what good looks like*.
|
|
42
|
+
- **Evaluation rubric** (criteria + scale): e.g. factual / on-spec / safe / tone.
|
|
43
|
+
- **Golden examples** (input → expected behavior/output): ≥ 5–10 representative ones, including hard/edge cases.
|
|
44
|
+
| Input | Expected behavior/output | Why |
|
|
45
|
+
|-------|--------------------------|-----|
|
|
46
|
+
| | | |
|
|
47
|
+
|
|
48
|
+
## 7. Eval strategy ⭐
|
|
49
|
+
- **Automated eval set** run on the golden set (scored by the §6 rubric) — this is the AI feature's "tests".
|
|
50
|
+
- **Prompt regression:** when changing prompt/model → re-run the eval, compare before/after scores.
|
|
51
|
+
- Pass threshold: `<TBD>` (e.g. average rubric score ≥ X, no safety case failing).
|
|
52
|
+
- Relation to DoD: add to [DEFINITION_OF_DONE.md](../DEFINITION_OF_DONE.md) for AI features.
|
|
53
|
+
|
|
54
|
+
## 8. Fallback & Human-in-the-loop ⭐
|
|
55
|
+
- When the model **fails / times out / is low-confidence** → what does the assistant do? (apologize + suggest / return partial / hand off to a human).
|
|
56
|
+
- **Human checkpoints (HITL):** which actions need human approval before execution?
|
|
57
|
+
- Behavior when a dependent tool/API fails.
|
|
58
|
+
|
|
59
|
+
## 9. Model, cost & performance
|
|
60
|
+
> Follow [PERFORMANCE_STANDARDS.md](../PERFORMANCE_STANDARDS.md) §2 (AI-specific).
|
|
61
|
+
- Model used (e.g. Claude Opus/Sonnet/Haiku) + rationale; **prompt caching REQUIRED** for static prompt parts.
|
|
62
|
+
- Token budget / target cost per request (ceiling).
|
|
63
|
+
- Target latency (p95).
|
|
64
|
+
|
|
65
|
+
## 10. Observability
|
|
66
|
+
- What to log (with PII redacted), how to assess quality *after* going to prod (collect feedback, sample review).
|
|
67
|
+
- Metrics to track (refusal rate, confidence, satisfaction…).
|
|
68
|
+
|
|
69
|
+
## 11. Acceptance Criteria
|
|
70
|
+
- [ ] <criterion 1 — measurable>
|
|
71
|
+
- [ ] Eval meets the §7 threshold
|
|
72
|
+
- [ ] §5 guardrails tested (including abuse cases)
|
|
73
|
+
|
|
74
|
+
## 12. API / Interface contract (for parallelization)
|
|
75
|
+
> Must be locked before spawning FE & BE in parallel (see AGENCY_WORKFLOW Phase 2/3).
|
|
76
|
+
|
|
77
|
+
## 13. Decision Log
|
|
78
|
+
| Date | Question/Issue | Decision | Decided by | Rationale |
|
|
79
|
+
|------|----------------|----------|------------|-----------|
|
|
80
|
+
| | | | | |
|
|
81
|
+
|
|
82
|
+
## 14. Assumptions Register
|
|
83
|
+
| Assumption | Status (pending/confirmed/rejected) |
|
|
84
|
+
|------------|-------------------------------------|
|
|
85
|
+
| | |
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Project Active State
|
|
2
|
+
|
|
3
|
+
**Last Updated:** {{DATE}}
|
|
4
|
+
**Current Global Phase:** 0 — Initialization & Setup
|
|
5
|
+
|
|
6
|
+
> 📌 **Bảng "Active Features" dưới đây LÀ backlog bền vững xuyên session.** Đây là nguồn trạng thái chính khi resume.
|
|
7
|
+
> `TaskCreate`/`TaskList` chỉ sống **trong session hiện tại** (in-memory, mất khi đóng session) — chỉ dùng để theo dõi việc đang làm, KHÔNG dùng làm backlog dài hạn. Mỗi khi trạng thái một feature đổi → cập nhật bảng này và (nếu có) GitLab MR/issue tương ứng.
|
|
8
|
+
|
|
9
|
+
## Active Features in Pipeline
|
|
10
|
+
|
|
11
|
+
| Feature / Epic | Path | Phase hiện tại | Branch / MR | Status | PRD | TDD |
|
|
12
|
+
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|
|
13
|
+
| N/A | N/A | N/A | - | Idle | - | - |
|
|
14
|
+
|
|
15
|
+
## Blockers / Pending Actions
|
|
16
|
+
- Chờ Product Owner đề xuất feature/ý tưởng đầu tiên.
|
|
17
|
+
- Chốt tech stack → điền placeholder trong [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md).
|
|
18
|
+
- Chốt design direction → cập nhật [TEAM_ROSTER.md](./TEAM_ROSTER.md) §3.
|
|
19
|
+
|
|
20
|
+
## Session Resume Protocol
|
|
21
|
+
*AI khởi tạo session mới ĐỌC mục này:*
|
|
22
|
+
1. Đọc [AGENCY_WORKFLOW.md](./AGENCY_WORKFLOW.md) (SSOT) để nắm router & path.
|
|
23
|
+
2. Xem bảng "Active Features" ở trên + các **GitLab MR đang mở** (`git branch`, MR list) — KHÔNG dựa vào TaskList của session cũ (đã mất).
|
|
24
|
+
3. Theo path & phase của từng feature:
|
|
25
|
+
- **Read-only/Fast**: tiếp tục/hoàn tất rồi mở MR.
|
|
26
|
+
- **Standard/Full ở Phase 1–2**: tiếp tục brainstorming/planning với User (qua Plan Mode gate).
|
|
27
|
+
- **Standard/Full ở Phase 3–4**: mở PRD/TDD đã link, kiểm tra trạng thái code & branch, tái tạo task bằng `TaskCreate` cho session này, hỏi User trước khi resume code/test.
|
|
28
|
+
4. Cập nhật lại bảng này khi bắt đầu làm.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Agency Workflow — Single Source of Truth
|
|
2
|
+
|
|
3
|
+
> **Đây là tài liệu quy trình DUY NHẤT (canonical).** Mọi tài liệu khác (CLAUDE.md, AGENTS.md, TEAM_ROSTER.md, Serena memories) chỉ được **trỏ link** tới đây, KHÔNG được sao chép nội dung. Sửa quy trình → chỉ sửa file này.
|
|
4
|
+
|
|
5
|
+
AI đóng vai một software agency tinh gọn. Quy mô vận hành: **{{TEAM_SIZE}} + AI**, theo **{{BRANCHING_MODEL}}** (xem [BRANCHING.md](./BRANCHING.md)). Tiêu chí hoàn thành: xem [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md).
|
|
6
|
+
|
|
7
|
+
Persona (BA / Architect / Developer / QA / Scrum Master) là **lăng kính tư duy**, không phải nghi thức bắt buộc cho mọi việc — chi tiết ở [TEAM_ROSTER.md](./TEAM_ROSTER.md).
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 0. Quy tắc vàng
|
|
12
|
+
|
|
13
|
+
1. **Bắt đầu mọi yêu cầu bằng việc PHÂN LOẠI task** (bảng §1) → chọn đúng *path*. Đừng mặc định chạy full 5-phase cho mọi việc.
|
|
14
|
+
2. **Không lao vào code khi yêu cầu chưa rõ.** Với Standard/Full path, làm rõ scope trước.
|
|
15
|
+
3. **Gate = Plan Mode thật, không phải lời hứa.** Khi một path yêu cầu "Gate", dùng `EnterPlanMode` → trình kế hoạch → `ExitPlanMode` để User duyệt. Đây là cơ chế chặn được harness enforce, thay cho câu chữ "chờ sign-off".
|
|
16
|
+
4. **Cập nhật [ACTIVE_STATE.md](./ACTIVE_STATE.md)** khi bắt đầu / kết thúc một đơn vị công việc. Đây là backlog bền vững xuyên session (TaskCreate chỉ sống trong session hiện tại).
|
|
17
|
+
5. **Tuân [COMMUNICATION_PROTOCOL.md](./COMMUNICATION_PROTOCOL.md) trong mọi tương tác** — đặc biệt khi làm rõ yêu cầu: no silent assumptions, phân tầng độ chắc chắn, phân loại câu hỏi blocking/non-blocking, đóng vòng khi hiểu sai.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 1. Bảng phân loại task → workflow (ROUTER)
|
|
22
|
+
|
|
23
|
+
Khi nhận yêu cầu, tra bảng này trước để chọn path, branch, bước bắt buộc và DoD.
|
|
24
|
+
|
|
25
|
+
| # | Loại task | Trigger / ví dụ | Path | Gate | Branch | Bước bắt buộc | Skills / Tools | DoD rút gọn |
|
|
26
|
+
|---|---|---|---|---|---|---|---|---|
|
|
27
|
+
| 1 | **Q&A / Explain / Find code** | "Giải thích X", "tìm chỗ xử lý Y", "code này làm gì" | Read-only | Không | — | Trả lời trực tiếp, **không sửa file** | `gitnexus_query`, `gitnexus_context`, serena `find_symbol` | Trả lời đúng + trích `file:line`; không tạo branch/commit |
|
|
28
|
+
| 2 | **Chore / Docs / Config** | sửa README, đổi config, bump version, format | Fast | Không | `chore/` `docs/` | sửa → MR | — | build/lint xanh; không đổi hành vi runtime |
|
|
29
|
+
| 3 | **Bugfix nhỏ (khu trú)** | lỗi rõ nguyên nhân, ≤ ~2 file, không phải symbol dùng chung | Fast | Không (nhưng **bắt buộc repro test**) | `fix/` | `systematic-debugging` → viết test ĐỎ tái hiện bug → fix → test XANH → MR | systematic-debugging, test-driven-development, verification-before-completion | test tái hiện bug (đỏ→xanh); regression xanh; root cause ghi trong MR |
|
|
30
|
+
| 4 | **Hotfix (prod khẩn cấp)** | sự cố production cần vá gấp | Fast (expedited) | Không | `hotfix/` (off `main`) | fix tối thiểu + test → MR nhanh → backport về nhánh phát triển | systematic-debugging, verify | vá sự cố + test; đã backport; ghi lại để hậu kiểm |
|
|
31
|
+
| 5 | **Sửa / đổi logic tính năng đã có** | "đổi cách tính X", "thêm điều kiện cho Y", "đổi hành vi Z" | Standard | **CÓ** | `change/` | **impact analysis BẮT BUỘC** → đảm bảo/ bổ sung regression test → impl → QA review | `gitnexus_impact` (upstream), test-driven-development, code-review | impact đã báo cáo; regression + test mới xanh; `detect_changes` đúng phạm vi |
|
|
32
|
+
| 6 | **Refactor (KHÔNG đổi hành vi)** | "tách module", "đổi tên", "dọn code" | Standard | **CÓ** | `refactor/` | test XANH trước → impact analysis → đổi (dùng `gitnexus_rename`) → test XANH sau (không đổi) | gitnexus_rename, gitnexus_impact, simplify | cùng bộ test pass trước & sau; KHÔNG find-replace thủ công |
|
|
33
|
+
| 7 | **Feature mới** | "xây tính năng Z" | Full (5-phase) | **CÓ (2 gate: PRD + TDD)** | `feat/` | §3 đầy đủ | brainstorming, writing-plans, test-driven-development, design system, code-review, security-review | đủ [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md) |
|
|
34
|
+
| 8 | **Spike / Research / POC** | "nghiên cứu khả thi", "thử nghiệm cách tiếp cận" | Timeboxed | Không (timebox thay gate) | `spike/` (vứt đi) | timebox rõ ràng → output **doc khuyến nghị**; **KHÔNG merge code POC** vào main | deep-research, gitnexus_exploring | có doc kết luận + khuyến nghị; code POC không vào main |
|
|
35
|
+
|
|
36
|
+
### Escalation rule (nâng cấp path)
|
|
37
|
+
Một task đang ở **Fast path** mà phát hiện:
|
|
38
|
+
- chạm symbol có nhiều caller / `gitnexus_impact` trả về **MEDIUM trở lên**, HOẶC
|
|
39
|
+
- thay đổi lan ra **> 5 file**,
|
|
40
|
+
|
|
41
|
+
→ **dừng lại, nâng lên Standard path**: mở Plan Mode (gate), chạy & báo cáo impact analysis trước khi tiếp tục.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 2. Bốn path (định nghĩa)
|
|
46
|
+
|
|
47
|
+
### Read-only
|
|
48
|
+
Trả lời câu hỏi, đọc/giải thích code. Không branch, không gate, không commit. Ưu tiên `gitnexus_query`/`gitnexus_context` thay vì grep mù. Luôn trích dẫn `file:line`.
|
|
49
|
+
|
|
50
|
+
### Fast path
|
|
51
|
+
Cho việc nhỏ, rủi ro thấp (chore/docs/bugfix khu trú/hotfix).
|
|
52
|
+
1. Tạo branch đúng tiền tố (xem [BRANCHING.md](./BRANCHING.md)).
|
|
53
|
+
2. Thực hiện thay đổi. Nếu là **bugfix**: viết test tái hiện bug (đỏ) TRƯỚC khi sửa.
|
|
54
|
+
3. Self-review nhanh (`code-review` nếu muốn) + chạy test/lint.
|
|
55
|
+
4. Mở MR theo DoD "Fast" trong [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md).
|
|
56
|
+
> Không cần Plan sign-off. Nhưng nếu chạm trúng escalation rule → nâng lên Standard.
|
|
57
|
+
|
|
58
|
+
### Standard path
|
|
59
|
+
Cho thay đổi logic tính năng đã có & refactor.
|
|
60
|
+
1. **Gate**: `EnterPlanMode` → khảo sát + chạy `gitnexus_impact` (upstream) → trình kế hoạch nêu **blast radius + mức rủi ro** → `ExitPlanMode` chờ User duyệt.
|
|
61
|
+
2. Cảnh báo User nếu rủi ro **HIGH/CRITICAL** trước khi tiếp tục.
|
|
62
|
+
3. Implement theo TDD; refactor thì giữ test không đổi.
|
|
63
|
+
4. QA: spawn sub-agent review (`code-review` + `security-review` nếu chạm bề mặt nhạy cảm) + `gitnexus_detect_changes`.
|
|
64
|
+
5. MR theo DoD "Standard".
|
|
65
|
+
|
|
66
|
+
### Full path (5-phase) — chỉ cho Feature mới
|
|
67
|
+
Xem §3.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 3. Full path: 5 phase cho Feature mới
|
|
72
|
+
|
|
73
|
+
> Chỉ áp dụng cho task loại **#7 (Feature)**. Việc nhỏ KHÔNG chạy phase này.
|
|
74
|
+
|
|
75
|
+
### Phase 1 — Discovery & Scoping (lăng kính: Business Analyst)
|
|
76
|
+
1. Trigger skill `brainstorming`. **Áp dụng [COMMUNICATION_PROTOCOL.md](./COMMUNICATION_PROTOCOL.md)** xuyên suốt (cách hỏi, gắn nhãn giả định, kết mỗi vòng bằng tóm tắt + câu hỏi mở + giả định).
|
|
77
|
+
2. Làm rõ: User Personas, Business Flows, Edge Cases, mục tiêu, tiêu chí chấp nhận (acceptance criteria).
|
|
78
|
+
3. **Nếu là feature AI/assistant:** dùng **[template PRD_AI_FEATURE.md](./templates/PRD_AI_FEATURE.md)** — bắt buộc làm rõ các chiều đặc thù (hành vi khi mơ hồ, guardrails/refusal, định nghĩa "đúng" + golden examples, eval strategy, fallback/HITL), tham chiếu [INTERACTION_PATTERNS.md](./INTERACTION_PATTERNS.md) cho cách assistant giao tiếp với end-user.
|
|
79
|
+
4. Output: **PRD / Scope Document** (copy vào `docs/specs/YYYY-MM-DD-<feature>.md`, link vào ACTIVE_STATE) — gồm Decision Log + Assumptions Register.
|
|
80
|
+
5. **GATE 1 (Plan Mode):** trình PRD → `ExitPlanMode` → chờ User (Product Owner) duyệt.
|
|
81
|
+
|
|
82
|
+
### Phase 2 — Architecture & Planning (lăng kính: System Architect)
|
|
83
|
+
1. `gitnexus_exploring` để hiểu kiến trúc hiện tại (bỏ qua nếu vùng liên quan còn trống).
|
|
84
|
+
2. `gitnexus_impact` cho mọi sửa đổi lên code đã có.
|
|
85
|
+
3. **Threat modeling nhẹ (shift-left):** liệt kê bề mặt tấn công / dữ liệu nhạy cảm / quyền hạn ngay tại đây theo [SECURITY_STANDARDS.md](./SECURITY_STANDARDS.md) — đừng để dồn hết về QA.
|
|
86
|
+
4. **Đặt performance budget:** chốt latency/throughput/token-cost mục tiêu theo [PERFORMANCE_STANDARDS.md](./PERFORMANCE_STANDARDS.md) (điền `<TBD>`).
|
|
87
|
+
5. **Chốt API/interface contract** giữa các thành phần (FE↔BE, module↔module). *Đây là điều kiện tiên quyết để được phép parallelize ở Phase 3.*
|
|
88
|
+
6. Trigger `writing-plans` để chia nhỏ công việc → tạo task bằng `TaskCreate` (session-scoped) + ghi vào ACTIVE_STATE (bền vững).
|
|
89
|
+
7. Output: **Technical Design Document (TDD)** + Task list.
|
|
90
|
+
8. **GATE 2 (Plan Mode):** trình TDD → `ExitPlanMode` → chờ User duyệt cách tiếp cận kỹ thuật.
|
|
91
|
+
|
|
92
|
+
### Phase 3 — Implementation (lăng kính: Developer, có thể là sub-agent)
|
|
93
|
+
1. Cập nhật task `in_progress` (`TaskUpdate`) + ACTIVE_STATE.
|
|
94
|
+
2. Việc lớn → **delegate cho sub-agent** qua `Agent` tool. **Prompt sub-agent phải self-contained** (sub-agent KHÔNG tự kế thừa hội thoại/skill): nhúng link PRD/TDD, nêu rõ skill cần invoke, tiêu chí Done, file liên quan. Chi tiết: [TEAM_ROSTER.md](./TEAM_ROSTER.md).
|
|
95
|
+
3. **Parallelize CÓ ĐIỀU KIỆN:** chỉ spawn FE & BE song song **sau khi API contract (Phase 2.5) đã chốt**. Khi nhiều agent sửa file chồng nhau → `isolation: "worktree"`.
|
|
96
|
+
4. Developer áp dụng `test-driven-development`.
|
|
97
|
+
5. Frontend bám **một** design direction đã chốt (không gọi nhiều design skill cùng lúc — xem TEAM_ROSTER §design).
|
|
98
|
+
|
|
99
|
+
### Phase 4 — Quality Assurance (lăng kính: QA, sub-agent)
|
|
100
|
+
1. Spawn Code Reviewer / QA sub-agent (prompt self-contained).
|
|
101
|
+
2. QA chạy `verification-before-completion`, `security-review`, `systematic-debugging` khi cần. Đối chiếu [SECURITY_STANDARDS.md](./SECURITY_STANDARDS.md) + [PERFORMANCE_STANDARDS.md](./PERFORMANCE_STANDARDS.md) (gồm OWASP LLM Top 10 cho feature AI, và budget hiệu năng).
|
|
102
|
+
3. `gitnexus_detect_changes` để xác nhận không vỡ execution flow ngoài dự kiến.
|
|
103
|
+
4. Phải đạt [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md) (mức Full) trước khi merge.
|
|
104
|
+
|
|
105
|
+
### Phase 5 — Handover & Retro (lăng kính: DevOps / Scrum Master)
|
|
106
|
+
1. Trigger `finishing-a-development-branch` → mở/merge MR theo [BRANCHING.md](./BRANCHING.md).
|
|
107
|
+
2. Cập nhật **CLAUDE.md** nếu có quyết định kiến trúc mới (chỉ ghi cái mới, không lặp).
|
|
108
|
+
3. **Retro nhẹ (3 dòng):** cái gì chạy tốt / cái gì vướng / 1 cải tiến cho lần sau — ghi vào ACTIVE_STATE hoặc MR.
|
|
109
|
+
4. Lưu ngữ cảnh dự án vào Serena memory (con trỏ, không lặp nội dung).
|
|
110
|
+
5. Đánh dấu task `completed` + cập nhật ACTIVE_STATE.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 4. Tài liệu liên quan
|
|
115
|
+
| File | Nội dung |
|
|
116
|
+
|------|----------|
|
|
117
|
+
| [TASK router §1](#1-bảng-phân-loại-task--workflow-router) | Chọn path theo loại task |
|
|
118
|
+
| [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md) | Tiêu chí hoàn thành đo được (theo path) |
|
|
119
|
+
| [BRANCHING.md](./BRANCHING.md) | GitLab flow, đặt tên nhánh, Conventional Commits |
|
|
120
|
+
| [TEAM_ROSTER.md](./TEAM_ROSTER.md) | Persona + quy tắc delegate sub-agent + design direction |
|
|
121
|
+
| [ACTIVE_STATE.md](./ACTIVE_STATE.md) | Trạng thái pipeline + resume protocol |
|
|
122
|
+
| [COMMUNICATION_PROTOCOL.md](./COMMUNICATION_PROTOCOL.md) | Giao thức giao tiếp Human↔AI (làm rõ yêu cầu) |
|
|
123
|
+
| [templates/PRD_AI_FEATURE.md](./templates/PRD_AI_FEATURE.md) | Template PRD cho feature AI (các chiều cần làm rõ) |
|
|
124
|
+
| [INTERACTION_PATTERNS.md](./INTERACTION_PATTERNS.md) | Cách sản phẩm (assistant) giao tiếp với end-user |
|
|
125
|
+
| [SECURITY_STANDARDS.md](./SECURITY_STANDARDS.md) | Baseline bảo mật + OWASP LLM Top 10 |
|
|
126
|
+
| [PERFORMANCE_STANDARDS.md](./PERFORMANCE_STANDARDS.md) | Budget hiệu năng + chuẩn AI (prompt caching…) |
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Branching & Commit Convention
|
|
2
|
+
|
|
3
|
+
> Mô hình: **GitLab flow** cho nhóm nhỏ 2–5 người. `main` luôn ở trạng thái deploy được.
|
|
4
|
+
|
|
5
|
+
## Nhánh
|
|
6
|
+
- **`main`** — protected. KHÔNG commit/push trực tiếp. Mọi thay đổi vào qua **Merge Request (MR)**.
|
|
7
|
+
- Nhánh làm việc ngắn hạn, tạo từ `main`, đặt tên `<type>/<mô-tả-ngắn-kebab>`:
|
|
8
|
+
|
|
9
|
+
| Tiền tố | Dùng cho | Loại task (router) |
|
|
10
|
+
|---------|----------|--------------------|
|
|
11
|
+
| `feat/` | tính năng mới | #7 |
|
|
12
|
+
| `fix/` | sửa bug | #3 |
|
|
13
|
+
| `change/` | đổi logic tính năng đã có | #5 |
|
|
14
|
+
| `refactor/` | dọn code, không đổi hành vi | #6 |
|
|
15
|
+
| `chore/` | build, deps, config | #2 |
|
|
16
|
+
| `docs/` | chỉ tài liệu | #2 |
|
|
17
|
+
| `hotfix/` | vá khẩn cấp prod (off `main`) | #4 |
|
|
18
|
+
| `spike/` | nghiên cứu/POC (vứt đi, không merge code) | #8 |
|
|
19
|
+
|
|
20
|
+
Ví dụ: `feat/user-login`, `fix/null-cart-total`, `change/discount-rounding`.
|
|
21
|
+
|
|
22
|
+
## Merge Request
|
|
23
|
+
- **Bắt buộc ≥ 1 reviewer** duyệt trước khi merge.
|
|
24
|
+
- Phải thỏa [DEFINITION_OF_DONE.md](./DEFINITION_OF_DONE.md) của path tương ứng (CI xanh).
|
|
25
|
+
- **Squash merge** vào `main` để giữ lịch sử sạch (1 nhánh = 1 commit ý nghĩa).
|
|
26
|
+
- Xóa nhánh sau khi merge.
|
|
27
|
+
- Mô tả MR nêu rõ **what + why**, link PRD/TDD nếu là Standard/Full.
|
|
28
|
+
|
|
29
|
+
## Commit — Conventional Commits
|
|
30
|
+
Định dạng: `<type>(<scope>): <mô tả>` — type khớp tiền tố nhánh: `feat` `fix` `refactor` `chore` `docs` `test` `perf`.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
feat(auth): thêm đăng nhập bằng email
|
|
34
|
+
fix(cart): xử lý total null khi giỏ rỗng
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- BREAKING CHANGE: thêm `!` sau type (`feat!:`) hoặc footer `BREAKING CHANGE:`.
|
|
38
|
+
- KHÔNG dùng `--no-verify` / `--no-gpg-sign` trừ khi User yêu cầu rõ (hook sẽ chặn).
|
|
39
|
+
|
|
40
|
+
## Hotfix & backport
|
|
41
|
+
1. Tạo `hotfix/<...>` từ `main`.
|
|
42
|
+
2. Vá tối thiểu + test tái hiện → MR nhanh (vẫn cần review) → merge vào `main`.
|
|
43
|
+
3. **Backport**: cherry-pick/merge thay đổi đó về nhánh phát triển đang mở để không bị mất khi nhánh đó merge sau.
|
|
44
|
+
4. Ghi lại sự cố để hậu kiểm (Phase 5 retro).
|