|
1 | 1 | --- |
2 | 2 | name: engram-branch-pr |
3 | 3 | description: > |
4 | | - Branch and PR workflow for Engram contributors. |
5 | | - Trigger: When starting any change that will be proposed through GitHub. |
| 4 | + PR creation workflow for Engram following the issue-first enforcement system. |
| 5 | + Trigger: When creating a pull request, opening a PR, or preparing changes for review. |
6 | 6 | license: Apache-2.0 |
7 | 7 | metadata: |
8 | 8 | author: gentleman-programming |
9 | | - version: "1.0" |
| 9 | + version: "2.0" |
10 | 10 | --- |
11 | 11 |
|
12 | 12 | ## When to Use |
13 | 13 |
|
14 | 14 | Use this skill when: |
15 | | -- Starting a new feature, fix, or refactor |
16 | | -- Splitting work into multiple PRs |
17 | | -- Preparing a PR for review and merge |
| 15 | +- Creating a pull request for any change |
| 16 | +- Preparing a branch for submission |
| 17 | +- Helping a contributor open a PR |
18 | 18 |
|
19 | 19 | --- |
20 | 20 |
|
21 | | -## Core Rules |
| 21 | +## Critical Rules |
22 | 22 |
|
23 | | -1. Create a focused branch (`feat/*`, `fix/*`, `chore/*`). |
24 | | -2. Keep one logical scope per branch. |
25 | | -3. Push early and often to avoid large risky diffs. |
26 | | -4. Open PRs with intent, risk, and validation evidence. |
27 | | -5. Do not mix unrelated changes in the same PR. |
| 23 | +1. **Every PR MUST link an approved issue** — no exceptions |
| 24 | +2. **Every PR MUST have exactly one `type:*` label** |
| 25 | +3. **5 automated checks must pass** before merge is possible |
| 26 | +4. **Blank PRs without issue linkage will be blocked** by GitHub Actions |
28 | 27 |
|
29 | 28 | --- |
30 | 29 |
|
31 | | -## PR Structure |
| 30 | +## Workflow |
32 | 31 |
|
33 | | -Include: |
34 | | -- Problem statement (why this change exists) |
35 | | -- Solution summary (what changed) |
36 | | -- Risk notes (what could break) |
37 | | -- Validation (tests/commands executed) |
38 | | -- Follow-ups (what is intentionally out of scope) |
| 32 | +``` |
| 33 | +1. Verify issue has `status:approved` label |
| 34 | +2. Create branch: feat/*, fix/*, docs/*, refactor/*, chore/* |
| 35 | +3. Implement changes |
| 36 | +4. Run tests locally (unit + e2e) |
| 37 | +5. Open PR using the template |
| 38 | +6. Add exactly one type:* label |
| 39 | +7. Wait for 5 automated checks to pass |
| 40 | +``` |
39 | 41 |
|
40 | 42 | --- |
41 | 43 |
|
42 | | -## Merge Checklist |
| 44 | +## Branch Naming |
43 | 45 |
|
44 | | -- [ ] Branch name matches scope |
45 | | -- [ ] Diff is focused and reviewable |
46 | | -- [ ] Tests relevant to the change pass |
47 | | -- [ ] No temporary files or local artifacts included |
48 | | -- [ ] PR description explains why, not only what |
| 46 | +| Type | Branch pattern | Example | |
| 47 | +|------|---------------|---------| |
| 48 | +| Bug fix | `fix/<short-description>` | `fix/duplicate-observation-insert` | |
| 49 | +| Feature | `feat/<short-description>` | `feat/json-export-command` | |
| 50 | +| Docs | `docs/<short-description>` | `docs/api-reference-update` | |
| 51 | +| Refactor | `refactor/<short-description>` | `refactor/extract-query-sanitizer` | |
| 52 | +| Chore | `chore/<short-description>` | `chore/bump-bubbletea-v0.26` | |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## PR Body Format |
| 57 | + |
| 58 | +The PR template is at `.github/PULL_REQUEST_TEMPLATE.md`. Every PR body MUST contain: |
| 59 | + |
| 60 | +### 1. Linked Issue (REQUIRED) |
| 61 | + |
| 62 | +```markdown |
| 63 | +Closes #<issue-number> |
| 64 | +``` |
| 65 | + |
| 66 | +Valid keywords: `Closes #N`, `Fixes #N`, `Resolves #N` (case insensitive). |
| 67 | +The linked issue MUST have the `status:approved` label. |
| 68 | + |
| 69 | +### 2. PR Type (REQUIRED) |
| 70 | + |
| 71 | +Check exactly ONE in the template and add the matching label: |
| 72 | + |
| 73 | +| Checkbox | Label to add | |
| 74 | +|----------|-------------| |
| 75 | +| Bug fix | `type:bug` | |
| 76 | +| New feature | `type:feature` | |
| 77 | +| Documentation only | `type:docs` | |
| 78 | +| Code refactoring | `type:refactor` | |
| 79 | +| Maintenance/tooling | `type:chore` | |
| 80 | +| Breaking change | `type:breaking-change` | |
| 81 | + |
| 82 | +### 3. Summary |
| 83 | + |
| 84 | +1-3 bullet points of what the PR does. |
| 85 | + |
| 86 | +### 4. Changes Table |
| 87 | + |
| 88 | +```markdown |
| 89 | +| File | Change | |
| 90 | +|------|--------| |
| 91 | +| `path/to/file` | What changed | |
| 92 | +``` |
| 93 | + |
| 94 | +### 5. Test Plan |
| 95 | + |
| 96 | +```markdown |
| 97 | +- [x] Unit tests pass locally: `go test ./...` |
| 98 | +- [x] E2E tests pass locally: `go test -tags e2e ./internal/server/...` |
| 99 | +- [x] Manually tested the affected functionality |
| 100 | +``` |
| 101 | + |
| 102 | +### 6. Contributor Checklist |
| 103 | + |
| 104 | +All boxes must be checked: |
| 105 | +- Linked an approved issue |
| 106 | +- Added exactly one `type:*` label |
| 107 | +- Ran unit tests locally |
| 108 | +- Ran e2e tests locally |
| 109 | +- Docs updated if behavior changed |
| 110 | +- Conventional commit format |
| 111 | +- No `Co-Authored-By` trailers |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## Automated Checks (all 5 must pass) |
| 116 | + |
| 117 | +| Check | Job name | What it verifies | |
| 118 | +|-------|----------|-----------------| |
| 119 | +| PR Validation | `Check Issue Reference` | Body contains `Closes/Fixes/Resolves #N` | |
| 120 | +| PR Validation | `Check Issue Has status:approved` | Linked issue has `status:approved` | |
| 121 | +| PR Validation | `Check PR Has type:* Label` | PR has exactly one `type:*` label | |
| 122 | +| CI | `Unit Tests` | `go test ./...` passes | |
| 123 | +| CI | `E2E Tests` | `go test -tags e2e ./internal/server/...` passes | |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +## Conventional Commits |
| 128 | + |
| 129 | +``` |
| 130 | +<type>(<scope>): <short description> |
| 131 | +``` |
| 132 | + |
| 133 | +Type-to-label mapping: |
| 134 | + |
| 135 | +| Commit type | PR label | |
| 136 | +|-------------|----------| |
| 137 | +| `feat` | `type:feature` | |
| 138 | +| `fix` | `type:bug` | |
| 139 | +| `docs` | `type:docs` | |
| 140 | +| `refactor` | `type:refactor` | |
| 141 | +| `chore` | `type:chore` | |
| 142 | +| `feat!` / `fix!` | `type:breaking-change` | |
| 143 | + |
| 144 | +Examples: |
| 145 | +``` |
| 146 | +feat(cli): add --json flag to session list command |
| 147 | +fix(store): prevent duplicate observation insert on retry |
| 148 | +docs(contributing): update workflow documentation |
| 149 | +refactor(internal): extract search query sanitizer |
| 150 | +chore(deps): bump github.com/charmbracelet/bubbletea to v0.26 |
| 151 | +fix!: change session ID format |
| 152 | +``` |
| 153 | + |
| 154 | +--- |
| 155 | + |
| 156 | +## Commands |
| 157 | + |
| 158 | +```bash |
| 159 | +# Create branch |
| 160 | +git checkout -b feat/my-feature main |
| 161 | + |
| 162 | +# Run tests before pushing |
| 163 | +go test ./... # unit tests |
| 164 | +go test -tags e2e ./internal/server/... # e2e tests |
| 165 | + |
| 166 | +# Push and create PR |
| 167 | +git push -u origin feat/my-feature |
| 168 | +gh pr create --title "feat(scope): description" --body "Closes #N" |
| 169 | + |
| 170 | +# Add type label to PR |
| 171 | +gh pr edit <pr-number> --add-label "type:feature" |
| 172 | +``` |
0 commit comments