diff --git a/skills/projects/SKILL.md b/skills/projects/SKILL.md new file mode 100644 index 0000000..79e5970 --- /dev/null +++ b/skills/projects/SKILL.md @@ -0,0 +1,75 @@ +--- +name: projects +description: >- + Translate technical goals, user requests, and architecture plans into GitHub + Issues, Milestones, and Projects v2 boards with tiered complexity scaling. + Use when decomposing work, creating or updating GitHub issues or milestones, + or managing rolling planning horizons. Not for slice implementation (use + implement) or PR verification (use verify). +--- + +# Projects + +## Use when +- Decomposing a project, feature request, or technical plan into trackable GitHub units. +- Creating or updating GitHub Milestones, Projects v2 boards, and vertical-slice issues. +- Setting rolling planning horizons for multi-phase epics. +- Not for executing an approved issue slice: use `implement`. +- Not for black-box QA, PR promotion, or merge closeout: use `verify`. +- Not for standalone Git branch or worktree mechanics: use `git-manager`. + +## Steps +1. **Verify GitHub identity and contract.** Before checking remotes or editing + `AGENTS.md`, read [references/planning-contract.md](references/planning-contract.md). + Run `gh repo view --json url` to confirm a GitHub repository. If it fails or + `AGENTS.md` holds a legacy Gitea planning contract, halt and advise migrating + to GitHub or using standalone `gt-usage`. +2. **Reconcile specs and GitHub state.** Compare `ARCHITECTURE.md`, `ROADMAP.md`, + `docs/designs/*.md`, GitHub Issues, Milestones, and Projects v2 cards for + contradictions (zombie in-progress, premature completed, review orphan, + horizon divergence). If canonical docs lag behind `Completed` board cards, + hand off to `reconcile-docs` first. +3. **Select tier and decompose into vertical slices.** Before sizing, + decomposing, or auditing, read + [references/tiers-and-audit.md](references/tiers-and-audit.md). Assign + `Small`, `Medium`, or `Large` and emit + `### Project Board Policy: (Rationale)`. Map + work into deliverable outcome issues with test seams, Vertical Submodule TDD + Grouping, and falsifiable acceptance criteria (Context, Solution, Criteria). +4. **Run Independent Zero-Context Reproducibility Audit (`Medium`/`Large`).** + Spawn a clean-room subagent with the raw input manifest (pinned commit SHA, + specs, proposed issue markdown, milestone/board plan) to surface and resolve + material ambiguities before the human gate. +5. **Present plan for approval.** Emit + `### Reproducibility Audit: (Subagent: | Omitted: Small tier)` + alongside proposed milestones, due dates, board updates, issues, and any + `AGENTS.md` contract diff. Stop for approval before mutating GitHub or `AGENTS.md`. +6. **Execute GitHub operations.** Before running Projects v2 or milestone + mutations, read + [references/github-projects-v2.md](references/github-projects-v2.md). Use + `gh issue`, REST `gh api repos/{owner}/{repo}/milestones`, and `gh api graphql` + (`owner.projectV2` onboarding, `issue.projectItems` status updates, `DATE` + fields). Resolve all IDs dynamically; never hardcode or guess Node IDs or + construct `/milestone/1`. +7. **Verify state and formalize `AGENTS.md`.** Confirm created issue numbers, + canonical URLs, milestone due dates, and board columns. For `Medium`/`Large` + planning structure, record only the state-free `project_number: ` + contract in `AGENTS.md` (never rotating sprint state or GraphQL Node IDs). + +## Your call +- **Planning tier selection**: confirm `Small`, `Medium`, or `Large` ceremony. +- **Slice boundaries and milestones**: approve or revise proposed issues and due dates. +- **Batch mutations**: approve GitHub entity creation and `AGENTS.md` contract edits. + +## Done when +- Target milestones, board columns, and issues exist on GitHub with dynamically + verified IDs, canonical URLs, and falsifiable acceptance criteria. +- `AGENTS.md` holds an accurate, state-free `project_number` contract whenever + `Medium`/`Large` planning structure is created or updated. + +## Hands off to +- `implement`: to deliver a ready issue (`Suggested Next Step: /implement #`). +- `reconcile-docs`: when canonical docs lag behind completed cards (`Suggested Next Step: /reconcile-docs`). +- `git-manager`: for standalone branch or worktree operations. +- Emit one outcome-matched `Suggested Next Step:` on standalone turns; suppress + when delegated per [skeleton.md](../build-skill/references/skeleton.md). diff --git a/skills/projects/references/github-projects-v2.md b/skills/projects/references/github-projects-v2.md new file mode 100644 index 0000000..e2a215c --- /dev/null +++ b/skills/projects/references/github-projects-v2.md @@ -0,0 +1,204 @@ +# GitHub Projects v2 & Milestone Recipes + +Sole owner of GitHub Projects v2 GraphQL recipes and REST milestone commands. +Referenced by `projects` (onboarding, milestones, due dates), `implement` +(`Ready -> Work in Progress`), and `verify` (`Work in Progress -> Review`, +`Review -> Completed`, and abort/rejection reverts). + +--- + +## 1. Prerequisites & Anti-Hallucination Rules + +- Verify GitHub repository identity first: `gh repo view --json url`. +- Confirm `gh auth status` includes `repo` and `project` scopes before running + Projects v2 GraphQL mutations. +- **Never hardcode or guess IDs**: Never guess milestone sequence numbers, never + construct `/milestone/1` URLs, and never hardcode GraphQL Node IDs + (`PVT_...`, `PVTSSF_...`, `PVTI_...`, or single-select option IDs). Always + resolve IDs dynamically from live `gh api` responses. + +--- + +## 2. Fixed 5-Column Color Enum Map + +GitHub Projects v2 `Status` single-select options use fixed enum names +(`ProjectV2SingleSelectFieldOptionColor`), not hex codes: + +| Order | Column Name | GitHub Color Enum | +| :--- | :--- | :--- | +| `0` | `Backlog` | `GRAY` | +| `1` | `Ready` | `BLUE` | +| `2` | `Work in Progress` | `YELLOW` | +| `3` | `Review` | `PURPLE` | +| `4` | `Completed` | `GREEN` | + +When reconciling an existing board's `Status` field via `updateProjectV2Field`, +match existing options case-insensitively and preserve their option IDs where +possible so attached cards stay intact. Ensure all 5 canonical column names and +color enums above exist before moving cards. + +--- + +## 3. Onboarding New Issues onto a Board (`projects`) + +Use `owner.projectV2(number: $project_number)` when creating or onboarding an +issue that is not yet attached to the board. Replace `organization` with `user` +for user-owned projects. + +### Step 3a: Resolve `project_id` and Issue Global Node ID +```bash +gh api graphql \ + -F owner="" \ + -F repo="" \ + -F project_number= \ + -F issue_number= \ + -f query=' + query($owner: String!, $repo: String!, $project_number: Int!, $issue_number: Int!) { + organization(login: $owner) { + projectV2(number: $project_number) { id } + } + repository(owner: $owner, name: $repo) { + issue(number: $issue_number) { id url } + } + }' +``` + +*(For personal repositories, replace `organization(login: $owner)` with +`user(login: $owner)`.)* + +### Step 3b: Add Issue to Project (`addProjectV2ItemById`) +```bash +gh api graphql \ + -f project_id="" \ + -f content_id="" \ + -f query=' + mutation($project_id: ID!, $content_id: ID!) { + addProjectV2ItemById(input: {projectId: $project_id, contentId: $content_id}) { + item { id } + } + }' +``` + +--- + +## 4. Card Transitions via `issue.projectItems` (`implement`, `verify`) + +For board card moves, query `issue.projectItems` directly instead of scanning +`projectV2.items`. This avoids 100-item board pagination limits and resolves +`project_id`, `status_field_id`, the `PVTI_...` item ID, and all target column +`option_id`s in a single GraphQL request. + +### Step 4a: Single-Query Dynamic Resolution +```bash +gh api graphql \ + -F owner="" \ + -F repo="" \ + -F issue_number= \ + -f query=' + query($owner: String!, $repo: String!, $issue_number: Int!) { + repository(owner: $owner, name: $repo) { + issue(number: $issue_number) { + projectItems(first: 20) { + nodes { + id + project { + id + number + field(name: "Status") { + ... on ProjectV2SingleSelectField { + id + options { id name color } + } + } + } + } + } + } + } + }' +``` + +Filter `.data.repository.issue.projectItems.nodes[]` by +`select(.project.number == $project_number)` (using `project_number` from +`AGENTS.md`): +- If no matching node exists, halt and onboard the issue via Section 3 first. +- Verify the resolved `Status` field options include the target canonical column + name (`Backlog`, `Ready`, `Work in Progress`, `Review`, or `Completed`). + **Fail fast** with a clear column-name mismatch error if the target option is + missing; never fall back to a guessed option ID. + +### Step 4b: Move Card (`SINGLE_SELECT` Status Mutation) +```bash +gh api graphql \ + -f project_id="" \ + -f item_id="" \ + -f field_id="" \ + -f option_id="" \ + -f query=' + mutation($project_id: ID!, $item_id: ID!, $field_id: ID!, $option_id: String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $project_id + itemId: $item_id + fieldId: $field_id + value: { singleSelectOptionId: $option_id } + }) { + projectV2Item { id } + } + }' +``` + +--- + +## 5. Updating Projects v2 `DATE` Fields + +Resolve the `DATE` field ID dynamically from `project.fields(first: 50)` (or +`project.field(name: "")`), then run `updateProjectV2ItemFieldValue` +with an ISO-8601 `YYYY-MM-DD` string: + +```bash +gh api graphql \ + -f project_id="" \ + -f item_id="" \ + -f field_id="" \ + -f date="YYYY-MM-DD" \ + -f query=' + mutation($project_id: ID!, $item_id: ID!, $field_id: ID!, $date: Date!) { + updateProjectV2ItemFieldValue(input: { + projectId: $project_id + itemId: $item_id + fieldId: $field_id + value: { date: $date } + }) { + projectV2Item { id } + } + }' +``` + +--- + +## 6. REST Milestone & Issue Operations + +GitHub CLI does not expose a native `gh milestone` subcommand; manage milestones +through REST via `gh api repos/{owner}/{repo}/milestones`: + +```bash +# List open milestones (extract number, title, due_on, html_url) +gh api repos/{owner}/{repo}/milestones --paginate \ + --jq '.[] | {number, title, state, due_on, html_url}' + +# Create a milestone (due_on is optional ISO-8601 UTC) +gh api repos/{owner}/{repo}/milestones -X POST \ + -f title="" \ + -f description="" \ + -f due_on="YYYY-MM-DDTHH:MM:SSZ" + +# Update or close a milestone (use dynamically queried milestone number) +gh api repos/{owner}/{repo}/milestones/ -X PATCH \ + -f state="closed" + +# Create an issue attached to a milestone and verify returned URL +gh issue create \ + --title "" \ + --body-file \ + --milestone "" +``` diff --git a/skills/projects/references/planning-contract.md b/skills/projects/references/planning-contract.md new file mode 100644 index 0000000..2a066ca --- /dev/null +++ b/skills/projects/references/planning-contract.md @@ -0,0 +1,104 @@ +# Planning Contract & Canonical Board State Machine + +Sole owner of the repository `AGENTS.md` planning contract schema, the canonical +5-column GitHub Projects v2 board state machine, transition ownership, and the +scoped GitHub remote guard. Other delivery skills (`implement`, `verify`, +`code-review`, `reconcile-docs`) reference this file rather than duplicating it. + +--- + +## 1. Repository `AGENTS.md` Planning Contract Schema + +Each GitHub-managed repository stores minimal, human-readable planning +coordinates in its `AGENTS.md`: + +```yaml +# Planning Contract (owned by projects) +project_number: +``` + +### Contract Invariants +- **State-free coordinates only**: Store only `project_number: `. Never + hardcode rotating sprint state (active milestone numbers, open issue lists, + sprint names). +- **Zero brittle Node IDs**: Never store GraphQL Node IDs (`PVT_...`, + `PVTSSF_...`, `PVTI_...`, or single-select option IDs) in `AGENTS.md`. Skills + resolve all IDs dynamically at runtime via + [github-projects-v2.md](github-projects-v2.md). +- **Repo-scoped documentation paths**: Durable engineering specs, architecture + notes, and roadmaps live in repository-scoped `docs/` (`docs/designs/*.md`, + `docs/adr/`, `ARCHITECTURE.md`, `ROADMAP.md`). Ephemeral agent artifacts and + personal practice records live in gitignored `.internal/` at the repository + root. Never encode user home paths or external vault directories in a + repository planning contract. + +--- + +## 2. Canonical 5-Column Board State Machine + +All GitHub Projects v2 boards managed by the delivery loop use 5 canonical +`Status` column names paired with fixed GitHub `ProjectV2SingleSelectFieldOptionColor` +enums: + +```text +Backlog -> Ready -> Work in Progress -> Review -> Completed +``` + +| Order | Column | Fixed GitHub Color Enum | Entering Transition Owner | Trigger Event | +| :--- | :--- | :--- | :--- | :--- | +| `0` | `Backlog` | `GRAY` | `projects` (or `verify` on abort) | Issue created and onboarded, or abandoned/superseded Draft PR closed | +| `1` | `Ready` | `BLUE` | `projects` | Slice prioritized and ready for execution | +| `2` | `Work in Progress` | `YELLOW` | `implement` (or `verify` on merge rejection) | `implement` preflight passes (`Ready -> Work in Progress`); card stays here through Draft PR open, `code-review`, and rework; human merge rejection at `verify` Phase 3 runs `gh pr ready --undo` and moves `Review -> Work in Progress` | +| `3` | `Review` | `PURPLE` | `verify` | `verify` Phase 2 passes runtime QA + CI + `verdict=ready` gate and promotes the Draft PR (`gh pr ready`), moving `Work in Progress -> Review` | +| `4` | `Completed` | `GREEN` | `verify` | `verify` Phase 3 merges the PR on human approval and executes `Review -> Completed` directly | + +### Read-Only Skill Boundaries +- **`code-review`**: Strictly read-only regarding project boards. Never executes + board card moves. +- **`reconcile-docs`**: Strictly read-only regarding GitHub state. Never mutates + GitHub issues, pull requests, milestones, or project boards. + +--- + +## 3. Scoped GitHub Remote Guard + +Forge-dependent operations across the delivery loop (`projects`, `implement`, +`verify`, PR review publishing in `code-review`, and optional GitHub-state reads +in `reconcile-docs`) must verify GitHub repository identity before issuing forge +commands: + +```bash +gh repo view --json url +``` + +- **Why `gh repo view --json url`**: Resolves the active GitHub repository even + when using custom SSH host aliases or non-`origin` remotes. +- **Local-only exception**: Local diff reviews in `code-review` (when no open PR + exists or local-only mode is requested) and local git/doc reconciliation in + `reconcile-docs` run without requiring a GitHub remote. +- **Legacy Gitea contract detection**: If `gh repo view --json url` fails, or if + the repository's `AGENTS.md` contains a legacy Gitea planning contract (such + as Gitea `project_id`, `{Backlog..Completed -> column_id}` maps, or + `gitea-plan` sync rules), fail fast and advise the user to either migrate the + repository to GitHub or use standalone `gt-usage` outside the core delivery + loop. + +--- + +## 4. Meaningful Conflict Reconciliation + +When reconciling specs, roadmaps, and GitHub state in Step 2, never mechanically +mirror or silently mutate conflicting state. Detect and report semantic +conflicts before planning new work: + +- **Zombie In-Progress**: Issue or linked PR is closed on GitHub, but its card + still sits in `Backlog`, `Ready`, `Work in Progress`, or `Review`. +- **Premature Completed**: Card sits in `Completed`, but the issue remains open + or lacks a merged PR / commit on the default branch. +- **Review Orphan**: Card sits in `Review`, but no open ready-for-review PR + exists. +- **Horizon Divergence**: An open issue is assigned to a closed milestone or + diverges from the active milestone in `ROADMAP.md`. +- **Doc Lag**: `ARCHITECTURE.md`, `ROADMAP.md`, or `docs/designs/*.md` lags + behind `Completed` board cards. Hand off to `reconcile-docs` before + decomposing the next rolling milestone. diff --git a/skills/projects/references/tiers-and-audit.md b/skills/projects/references/tiers-and-audit.md new file mode 100644 index 0000000..0755f7c --- /dev/null +++ b/skills/projects/references/tiers-and-audit.md @@ -0,0 +1,124 @@ +# Project Sizing, Ceremony Tiers, and Reproducibility Audit + +Reference for `projects`. Guidelines for scaling planning ceremony to risk and +scope, structuring vertical-slice issues, and running clean-room reproducibility +audits on GitHub Issues and Projects v2. + +--- + +## 1. Core Axiom: Issues vs. Commits + +- An **Issue** represents an **independently deliverable outcome** (what is + built, verified, and closed by a pull request). It defines test seams and + falsifiable acceptance criteria (`Context`, `Solution`, `Acceptance Criteria`). +- A **Commit** represents an **atomic, reversible implementation checkpoint** + within an issue's branch. Commits compile and pass tests, but do not need to + close an entire issue on their own. +- **Anti-pattern**: Never create 1:1 GitHub issues for micro-commits (such as + "fix typo", "add helper function", or "clean up lint"). Group cohesive + checkpoints under one deliverable issue. +- **Vertical Submodule TDD Grouping**: Inside a multi-module issue, organize + acceptance criteria and TDD test seams vertically by submodule or capability + layer (for example, `parser` -> `validator` -> `cli`) rather than a single + horizontal "write all tests for the entire issue first" block, so `implement` + executes incremental Red-Green cycles per submodule. + +--- + +## 2. GitHub Planning Primitives + +Each GitHub primitive tracks a distinct dimension of delivery: + +- **Issue State (`OPEN` vs. `CLOSED`)**: Deliverable completion on the default branch. +- **Projects v2 `Status` Column (`Backlog`, `Ready`, `Work in Progress`, `Review`, `Completed`)**: + Active workflow stage. See [planning-contract.md](planning-contract.md) for + canonical colors and transition ownership, and + [github-projects-v2.md](github-projects-v2.md) for GraphQL recipes. +- **Milestone & Projects v2 `DATE` Fields**: Strategic delivery horizon and + target/due dates. + +--- + +## 3. Planning Ceremony Tiers & Project Board Policy + +| Tier | Typical Work | GitHub Primitives | Project Board Policy | Decomposition Rule | +| :--- | :--- | :--- | :--- | :--- | +| **Small** | Localized bugfix, doc update, dependency bump, routine chore (1 to 3 issues) | 1 to 3 Issues, single optional Milestone | **Omitted** by policy (issue tracker suffices) | Keep each issue concise (`Context`, `Solution`, `Acceptance Criteria`). Clean-room audit omitted. | +| **Medium** | Vertical feature slice, multi-step refactor, capability buildout (4 to 8 vertical slices) | 1 Milestone + 4 to 8 Issues | **Recommended** (5-column Projects v2 board) | Each issue has its own branch and Draft PR. Explicit numbered acceptance criteria and test seams. Mandatory clean-room audit. | +| **Large** | Architectural epic, platform cutover, multi-service evolution | Roadmap doc + Phased Rolling Milestones + Cross-Slice Dependency Map + Deliverable Issues | **Required** (5-column Projects v2 board coordinates rolling horizons) | Source of truth stays in repo docs (`ARCHITECTURE.md`, `ROADMAP.md`, `docs/designs/*.md`, `docs/adr/`). Mandatory clean-room audit. | + +### Deterministic Output Headers (Subagent Provenance Guard) +Every planning proposal must emit both headers verbatim before asking for +approval: + +```markdown +### Project Board Policy: (Rationale) +### Reproducibility Audit: (Subagent: `` | `Omitted: Small tier`) +``` + +- For `Medium` and `Large` tiers, `Subagent: ` must record the + real conversation ID returned by the clean-room auditor subagent. Never + fabricate a placeholder ID or claim `Passed` without running the subagent. +- `Omitted: Small tier` is valid only when the selected tier is `Small`. + +--- + +## 4. Independent Zero-Context Reproducibility Audit + +Mandatory for `Medium` and `Large` plans before presenting the decomposition for +approval (Step 5). Spawn a fresh-context subagent with zero prior conversation +history to verify that every proposed slice is executable without guesswork. + +### Input Manifest (Strict Clean-Room) +Pass strictly raw artifacts and pinned repository state to the auditor: +1. Pinned repository root and commit SHA (`git rev-parse HEAD`). +2. Canonical specifications (`ARCHITECTURE.md`, `ROADMAP.md`, `docs/designs/*.md`, `docs/adr/*.md`). +3. Proposed raw issue titles, descriptions, test seams, and acceptance criteria markdown. +4. Proposed milestone titles, due dates, and Projects v2 board specifications. +5. Declared asset paths and prerequisite environment variables. + +### Auditor Report Schema +The clean-room auditor must report directly from the manifest across five +explicit sections, without inventing missing requirements or fabricating +unchecked claims: + +1. **Reconstructed from Source Artifacts**: Scope and sequence directly supported by source text. +2. **Inferred Requirements**: Deductions made from titles or conventions lacking explicit spec text. +3. **Undetermined Seams**: Gaps or ambiguities that cannot be resolved without guessing. +4. **Materiality Classification**: + - *Material*: Forces an implementer to guess about scope, behavior, acceptance criteria, or prerequisites. + - *Non-Material*: Cosmetic or self-evident convention. +5. **Concrete Remediation Plan**: Specific edits to specs, assets, or issue criteria needed to resolve every *Material* ambiguity. + +Resolve all *Material* findings before requesting human approval. Record the +auditor's exact outcome (`Passed` if zero material findings, `Remediated` after +applying fixes) and `` in the `### Reproducibility Audit:` +header. + +--- + +## 5. Rolling Horizons for Large Projects + +Avoid waterfall decomposition where distant work is pre-created weeks before +execution: + +1. **Active Milestone (Immediate Horizon)**: Decompose into concrete vertical + slice issues with falsifiable acceptance criteria and a cross-slice + dependency map. +2. **Future Milestones (Deferred Horizons)**: Represent as high-level milestones + with target due dates or single coarse placeholder issues. +3. **Architecture Synchronization**: Run `reconcile-docs` to sync canonical docs + against completed work before decomposing the next rolling milestone. + +--- + +## 6. Organization-Level Shared Projects v2 Boards + +For multi-repository architectures coordinated under one GitHub organization: +- Create one shared Projects v2 board at the organization level and record its + `project_number` in each participating repository's `AGENTS.md`. +- Onboard issues from child repositories onto that shared board using + `organization(login: $owner).projectV2(number: $project_number)` and + `addProjectV2ItemById` (see [github-projects-v2.md](github-projects-v2.md)). +- Keep architectural strategy and cross-repo roadmaps in the hub repository's + `docs/` directory while the shared board tracks unified delivery status.