@anyberg/agent-conventions 1.0.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.
Files changed (42) hide show
  1. package/.claude-plugin/marketplace.json +19 -0
  2. package/.claude-plugin/plugin.json +9 -0
  3. package/.codex-plugin/plugin.json +6 -0
  4. package/AGENTS.md +24 -0
  5. package/README.md +244 -0
  6. package/agents/code-reviewer.md +36 -0
  7. package/agents/docs-change-steward.md +71 -0
  8. package/agents/feature-planner.md +24 -0
  9. package/agents/implementation.md +35 -0
  10. package/agents/refactoring-planner.md +38 -0
  11. package/agents/repo-search.md +32 -0
  12. package/agents/test-runner.md +34 -0
  13. package/bin/cli.js +311 -0
  14. package/gemini-extension.json +5 -0
  15. package/package.json +47 -0
  16. package/plugin.json +12 -0
  17. package/skills/api-design/SKILL.md +18 -0
  18. package/skills/architecture-planning/SKILL.md +113 -0
  19. package/skills/backlog-management/SKILL.md +73 -0
  20. package/skills/backlog-management/backends/github-issues.md +37 -0
  21. package/skills/backlog-management/backends/markdown.md +34 -0
  22. package/skills/backlog-management/scripts/detect-backend.sh +30 -0
  23. package/skills/backlog-management/scripts/generate-policy.sh +49 -0
  24. package/skills/code-review/SKILL.md +95 -0
  25. package/skills/code-standards/SKILL.md +73 -0
  26. package/skills/docs-standards/SKILL.md +95 -0
  27. package/skills/git-conventions/SKILL.md +95 -0
  28. package/skills/hatch-workflow/SKILL.md +147 -0
  29. package/skills/python-best-practices/SKILL.md +107 -0
  30. package/skills/python-coding-guidelines/SKILL.md +58 -0
  31. package/skills/python-design-patterns/SKILL.md +28 -0
  32. package/skills/rust-best-practices/SKILL.md +171 -0
  33. package/skills/rust-coding-guidelines/SKILL.md +77 -0
  34. package/skills/rust-design-patterns/SKILL.md +83 -0
  35. package/skills/task-workflow/SKILL.md +122 -0
  36. package/skills/tech-debt/SKILL.md +41 -0
  37. package/skills/test-driven-development/SKILL.md +113 -0
  38. package/skills/testing-strategy/SKILL.md +35 -0
  39. package/skills/typescript-coding-guidelines/SKILL.md +55 -0
  40. package/src/plan.js +116 -0
  41. package/src/targets.js +95 -0
  42. package/src/write.js +184 -0
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env bash
2
+ # Prints: github-issues | markdown | none
3
+ set -euo pipefail
4
+ root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
5
+ policy="$root/.planning/policy.yml"
6
+
7
+ if [[ -f "$policy" ]]; then
8
+ # POSIX classes, not \s: BSD sed (macOS) treats \s as a literal 's', which
9
+ # leaves the value padded and makes `backend: auto` read as an explicit backend.
10
+ explicit="$(grep -E '^[[:space:]]*backend:' "$policy" | head -1 \
11
+ | sed -E 's/.*backend:[[:space:]]*//; s/[[:space:]]*#.*//; s/[[:space:]]+$//' || true)"
12
+ if [[ -n "${explicit:-}" && "$explicit" != "auto" ]]; then
13
+ if [[ "$explicit" == "github-issues" && -f "$root/BACKLOG.md" && ! -f "$root/.planning/backlog-migration.json" ]] \
14
+ && grep -qE '^\| *(LMS|INFRA|DEV|[0-9]{3})' "$root/BACKLOG.md"; then
15
+ echo "markdown # policy says github-issues but migration incomplete" >&2
16
+ echo markdown; exit 0
17
+ fi
18
+ echo "$explicit"; exit 0
19
+ fi
20
+ fi
21
+
22
+ remote="$(git -C "$root" remote get-url origin 2>/dev/null || true)"
23
+ if [[ "$remote" == *github.com* ]] && gh auth status >/dev/null 2>&1; then
24
+ if [[ "$(gh api "repos/{owner}/{repo}" --jq .has_issues 2>/dev/null)" == "true" ]]; then
25
+ echo github-issues; exit 0
26
+ fi
27
+ fi
28
+
29
+ if [[ -f "$root/BACKLOG.md" ]]; then echo markdown; exit 0; fi
30
+ echo none; exit 1
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env bash
2
+ # Generates <root>/.planning/policy.yml from the plugin's best-practice
3
+ # template if it does not already exist. Idempotent: never touches an
4
+ # existing file. Prints a human-readable report of what it generated.
5
+ set -euo pipefail
6
+
7
+ root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
8
+ target="$root/.planning/policy.yml"
9
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
+ template="$script_dir/../../../policy.example.yml"
11
+
12
+ if [[ -f "$target" ]]; then
13
+ echo "policy.yml already exists at $target — leaving it untouched."
14
+ exit 0
15
+ fi
16
+
17
+ if [[ ! -f "$template" ]]; then
18
+ echo "Template not found at $template — cannot generate policy.yml." >&2
19
+ exit 1
20
+ fi
21
+
22
+ backend="markdown"
23
+ reason="no GitHub remote, no gh auth, or Issues not enabled"
24
+ remote="$(git -C "$root" remote get-url origin 2>/dev/null || true)"
25
+ if [[ "$remote" == *github.com* ]] && gh auth status >/dev/null 2>&1; then
26
+ if [[ "$(gh api "repos/{owner}/{repo}" --jq .has_issues 2>/dev/null)" == "true" ]]; then
27
+ backend="github-issues"
28
+ reason="origin is on github.com, gh is authenticated, and Issues is enabled"
29
+ fi
30
+ fi
31
+
32
+ mkdir -p "$root/.planning"
33
+ sed "s/backend: auto/backend: $backend/" "$template" > "$target"
34
+
35
+ cat <<EOF
36
+ Generated $target — no existing policy.yml was found.
37
+
38
+ Detected:
39
+ backlog.backend = $backend ($reason)
40
+
41
+ Everything else uses the best-practice defaults documented inline in the
42
+ generated file (commit types, branch format, versioning, autonomous limits,
43
+ ID scheme, etc.) — none of these were detected from your repo, they are
44
+ starting points.
45
+
46
+ This file is now yours: edit any value directly at any time, nothing
47
+ regenerates or restarts it, and it will not be overwritten automatically
48
+ again.
49
+ EOF
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: code-review
3
+ description: Review code changes on the current branch or PR before merge, in any language. Detects the languages in the diff and applies the matching guideline skill (python-coding-guidelines, typescript-coding-guidelines, rust-coding-guidelines). Use for PR reviews, branch audits, test adequacy checks, and as the independent reviewer step in task-workflow merge readiness. Constructive tone, actionable findings.
4
+ ---
5
+
6
+ # Code Review
7
+
8
+ Structured review of code modified on the current branch, focusing on correctness and edge cases, readability and maintainability, idiomatic usage per language, typing quality, test coverage of business logic, KISS, pragmatic SOLID, and separation of concerns.
9
+
10
+ Uses constructive, collaborative phrasing ("Have you considered ...?") with practical suggestions.
11
+
12
+ ## When to use
13
+
14
+ - Reviewing a pull request or branch before merge
15
+ - Acting as the independent reviewer in **task-workflow** row 12
16
+ - Auditing recent changes for quality
17
+ - Improving test strategy for new functionality
18
+
19
+ ## Reviewer independence
20
+
21
+ When invoked as the independent reviewer, the reviewer receives only: the diff, the backlog item (goal and acceptance criteria), and the tests. It does not receive the author's reasoning, plan, or log. It runs in a fresh context or as a separate subagent. The author never approves their own PR.
22
+
23
+ ## Workflow
24
+
25
+ ### 1) Collect changed files
26
+
27
+ ```bash
28
+ git fetch origin
29
+ base=$(git merge-base HEAD origin/main)
30
+ git diff --name-only "$base"...HEAD
31
+ ```
32
+
33
+ Group by language from extension: `.py` → python-coding-guidelines; `.ts .tsx .js .jsx` → typescript-coding-guidelines; `.rs` → rust-coding-guidelines. Load each applicable guideline skill plus **code-standards**. Files with no matching guideline (SQL, YAML, shell, Terraform) are reviewed against the universal checks only. If no reviewable files changed, report that and stop.
34
+
35
+ ### 2) Review each changed file
36
+
37
+ Universal checks, every language:
38
+
39
+ 1. **Correctness**: bugs, missed edge cases, failure modes, error handling, input validation at boundaries.
40
+ 2. **Security**: authz on every new endpoint or query path, no secrets in code or logs, no injection via string-built queries or shell, no new dependency without a human label.
41
+ 3. **Tests**: business logic and complex behaviour tested; critical paths, edge cases, regressions covered; no test deleted or skipped without justification; no exhaustive tests demanded for trivial wrappers.
42
+ 4. **Design**: KISS, cohesion, dependency direction, interface clarity, split overly complex units.
43
+ 5. **Scope**: diff matches the acceptance criteria, no unrelated changes, no drive-by refactors outside task scope.
44
+ 6. **Docs**: `CHANGELOG.md` and `.planning/architecture.md` updated when behaviour or structure changed.
45
+
46
+ Language-specific checks:
47
+
48
+ **Python**
49
+ - Google Python Style Guide alignment, naming, docstrings, clear control flow
50
+ - Public APIs and core logic typed; precise hints; no unnecessary `Any`
51
+ - Idiomatic constructs, no overengineering
52
+
53
+ **TypeScript / JavaScript**
54
+ - `strict` respected; `unknown` over `any`; `as` only with documented safety reasoning; `@ts-expect-error` only with a comment
55
+ - Discriminated unions and `never` exhaustiveness on sum types
56
+ - Runtime validation (zod or equivalent) at every external boundary: request bodies, env, third-party responses
57
+ - Async errors handled; no swallowed `.catch`; domain error classes with `cause`
58
+ - Named exports, import order, no circular imports
59
+ - Changed behaviour has a unit test or a Playwright test; stubs preferred over full module mocks
60
+ - Frontend: accessible markup (labels, roles, keyboard), no layout done with `any`-typed props
61
+
62
+ **Rust**
63
+ - Per rust-coding-guidelines: ownership clarity, error types with `thiserror` or equivalent, no `unwrap` in library paths, clippy clean
64
+
65
+ ### 3) Prioritise findings
66
+
67
+ - **High**: likely bug, missing critical test, unsafe behaviour, authz gap, scope violation
68
+ - **Medium**: maintainability risk, weak typing, design concern, missing boundary validation
69
+ - **Low**: style or readability polish
70
+
71
+ ### 4) Constructive language
72
+
73
+ Prefer "Have you considered handling ...?", "Would it simplify this if ...?", "Could this be split into ... for clearer separation?". Avoid "This is wrong."
74
+
75
+ ### 5) Actionable suggestions
76
+
77
+ Every significant finding: why it matters, concrete improvement, optional code sketch.
78
+
79
+ ## Output format
80
+
81
+ 1. **Summary**: scope reviewed (files, languages), overall impression, verdict `approve` | `request-changes` | `needs-human`.
82
+ 2. **Findings by priority**: High / Medium / Low, file + location, observation + suggestion.
83
+ 3. **Testing assessment**: what is adequately tested, what critical behaviour is not.
84
+ 4. **Refactor opportunities**: KISS simplifications, separation of concerns, idiomatic upgrades.
85
+ 5. **Acceptance criteria check** (independent reviewer only): each criterion with met / not met / cannot verify.
86
+
87
+ `needs-human` is mandatory when the diff touches a `policy.autonomous.require_human_review_if_touches` path, adds a dependency, or changes a public API or schema.
88
+
89
+ ## Quality checks before finishing
90
+
91
+ - Reviewed only changed branch files, or stated the deviation
92
+ - Loaded the guideline skill for every language present
93
+ - Included typing, security, and testing assessment
94
+ - Called out complexity with simplification options
95
+ - Verdict stated explicitly
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: code-standards
3
+ description: Use when writing code, running linters, or reviewing pull requests. Covers universal cross-language code rules (style, naming, error handling, imports, testing), testing boundaries, language style-guide loading, and semantic versioning.
4
+ ---
5
+
6
+ # Code Standards
7
+
8
+ Enforces consistent code quality and architectural boundaries.
9
+
10
+ ## General Rules
11
+
12
+ ### Testing Boundaries
13
+ - **Strict separation:** no implementation in test files, no test code in implementation files.
14
+ - Test files are for validation; implementation files are for logic.
15
+ - Shared test utilities go in a dedicated `test-utils` or `testing` module.
16
+
17
+ ### Style Guides
18
+
19
+ Load language skills based on the files being changed. Each language skill carries only **language-specific** idioms, type-system usage, and tooling; the **Universal Code Rules** below apply to every language.
20
+
21
+ - **Python** (`.py`, `pyproject.toml`, `requirements.txt`): load `python-best-practices` + `python-coding-guidelines`; also load `python-design-patterns` when designing or refactoring component structure
22
+ - **TypeScript / JavaScript** (`.ts`, `.tsx`, `.js`, `.jsx`): load `typescript-coding-guidelines`
23
+ - **Rust** (`.rs`, `Cargo.toml`): load `rust-best-practices` + `rust-coding-guidelines`; also load `rust-design-patterns` when designing or refactoring component structure
24
+ - **Docs** (`.md`, `README`, `CHANGELOG`, role/layer docs): load `docs-standards`
25
+ - **Hatch projects**: load `hatch-workflow` for test, lint, and build entrypoints
26
+
27
+ ### Semantic Versioning
28
+ - **Source of truth:** `pyproject.toml` (Python) or `package.json` (Node.js/TypeScript)
29
+ - Format: `MAJOR.MINOR.PATCH` (e.g., `1.2.3`)
30
+ - Bump version when cutting a release alongside a commit that updates CHANGELOG.md
31
+
32
+ ### Conciseness
33
+ - Answers are short, no loss of information.
34
+ - "Fix this: X" > "We need to fix this: X"
35
+ - Comments explain *why*, not *what*; code is self-documenting.
36
+
37
+ ## Universal Code Rules
38
+
39
+ Language-agnostic rules shared across Python, TypeScript, and Rust. The language coding-guidelines skills add the specifics (syntax, mechanisms, tooling) on top of these.
40
+
41
+ ### Style
42
+ - Keep each commit/PR focused on a single stated purpose — exclude unrelated changes even if conceptually related (in Gerrit-style repos, each commit *is* a PR).
43
+ - Wrap code identifiers in backticks in user-facing messages (errors, warnings, logs).
44
+ - Centralize validation at one layer — validate/parse into a trusted type once at the boundary, then rely on it; prevents validation drift.
45
+ - Extract duplicated logic into a shared helper after 2+ occurrences — refactor rather than fork a parallel implementation.
46
+ - Consolidate duplicate logic across conditional branches (combined conditions, extracted variables, hoisted shared code).
47
+ - Remove commented-out code, unused definitions, and superseded implementations — version control preserves history.
48
+ - Inline single-use helpers that only wrap field/property access or delegation — removes needless indirection.
49
+ - Scope helpers and constants to their single usage site — don't hoist to module/crate root "just in case".
50
+ - Compile static regex patterns once as module-level constants — avoid recompiling on every call.
51
+
52
+ ### Naming
53
+ - Drop redundant prefixes when context is clear — `Config.description`, not `Config.config_description`.
54
+ - Use specific names that convey meaning (`user_id`, `order_id`) over generic `id`, `name`, `data`.
55
+ - Boolean functions/variables read as predicates — `is_*`, `has_*`, `can_*`.
56
+ - Avoid redundant type suffixes (`Value`, `Type`, `Class`, `List`, `Str`) when the type is already clear.
57
+ - Rename functions/methods when their behavior changes — names must reflect actual scope, return values, and abstraction level.
58
+
59
+ ### Error Handling
60
+ - Use domain-specific error types and preserve the cause chain when wrapping or re-raising (see each language skill for the mechanism).
61
+ - Don't use assertions as error handling — raise/throw a descriptive error including the relevant identifiers.
62
+ - Validate inputs before expensive work — fail fast.
63
+ - Catch specific error types, not a blanket catch-all, when the failure modes are known.
64
+
65
+ ### Imports
66
+ - Place imports at the top of the file — no inline imports inside functions unless intentional, documented lazy-loading.
67
+ - Remove unused and duplicate imports.
68
+
69
+ ### Testing
70
+ - Remove tests when redundant, obsolete, or duplicative — each test should verify distinct, currently-existing behavior.
71
+ - Test behavior through the public interface, not private internals.
72
+ - Use descriptive test names that read as sentences.
73
+ - Don't suppress coverage to hide gaps — write the test; only mark genuinely unreachable paths.
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: docs-standards
3
+ description: Use when writing or updating documentation — READMEs, CHANGELOGs, role/layer docs, ADRs, or API references. Covers doc placement, changelog format, the mandatory role-doc layout, writing style, and when to hand off to the docs-change-steward agent.
4
+ ---
5
+
6
+ # Documentation Standards
7
+
8
+ Keeps repository documentation consistent, factual, and in sync with the code it describes.
9
+
10
+ ## When to Load
11
+
12
+ Load this skill when:
13
+
14
+ - Writing or editing `.md` files (README, guides, runbooks)
15
+ - Adding a `CHANGELOG.md` entry or preparing release notes
16
+ - Creating or updating role docs (`docs/roles/*.md`) or layer docs
17
+ - Documenting a public API, module, or behavioural change
18
+ - Reviewing a pull request that changes documentation
19
+
20
+ For **multi-file doc synchronisation** after a code change — mapping a diff to every affected page and maintaining release traceability — hand off to the **docs-change-steward** agent, which enforces these same standards at scale.
21
+
22
+ ## Where Documentation Lives
23
+
24
+ | Doc | Location | Owning skill / agent |
25
+ |-----|----------|----------------------|
26
+ | Project overview | `README.md` | docs-standards |
27
+ | Release history | `CHANGELOG.md` | docs-standards + code-standards (versioning) |
28
+ | System-as-is + ADRs | `.planning/architecture.md` | architecture-planning |
29
+ | Role behaviour | `docs/roles/*.md` | docs-change-steward |
30
+ | Layer / locked-version tables | layer docs | docs-change-steward |
31
+ | Task / backlog records | `.planning/tasks/`, `BACKLOG.md` | task-workflow, backlog-management |
32
+
33
+ Keep each doc in its canonical location. Do not duplicate the same information across files — link instead.
34
+
35
+ ## Writing Style
36
+
37
+ - **Factual and concise.** Describe what is true now; never invent versions, dates, or behaviour.
38
+ - **Explain *why*, not *what*.** The code shows *what*; docs add rationale and context.
39
+ - **Match existing terminology.** Reuse the repo's nouns and headings; don't introduce synonyms.
40
+ - **Prefer tables and short lists** over long prose for reference material.
41
+ - **Imperative, active voice** in instructions ("Run", not "You should run").
42
+
43
+ ## Markdown Conventions
44
+
45
+ - One `#` H1 per file (the title); nest headings without skipping levels.
46
+ - Fenced code blocks always carry a language hint (` ```bash `, ` ```python `).
47
+ - Use relative links between repo docs so they survive clones and moves.
48
+ - Wrap file names, paths, commands, and identifiers in backticks.
49
+
50
+ ## CHANGELOG Format
51
+
52
+ Follow *Keep a Changelog* with Semantic Versioning. The version source of truth is `pyproject.toml` (Python) or `package.json` (Node/TypeScript) per **code-standards**.
53
+
54
+ ```markdown
55
+ ## [1.4.0] - 2025-01-30
56
+ ### Added
57
+ - Short, user-facing description of the change.
58
+ ### Fixed
59
+ - ...
60
+ ```
61
+
62
+ - Group entries under `Added`, `Changed`, `Fixed`, `Removed`, `Deprecated`, `Security`.
63
+ - Add an entry **only when public or observable behaviour changes** (mirrors **task-workflow** merge-readiness step 5).
64
+ - Bump the version and update `CHANGELOG.md` in the same commit that cuts the release (**code-standards** → Semantic Versioning).
65
+
66
+ ## Role Doc Layout (mandatory)
67
+
68
+ When creating or updating a role document under `docs/roles/*.md`, use this exact top-level section order so files stay consistent with the **docs-change-steward** agent:
69
+
70
+ 1. `## What is this role?`
71
+ 2. `## What does this role do?`
72
+ 3. `## Configuration`
73
+ 4. `## Files and Templates`
74
+ 5. `## Other Important Information` (only if needed)
75
+
76
+ Rules:
77
+
78
+ - Do not add alternative top-level headings (no "Overview", "Features", "Requirements").
79
+ - Omit `Other Important Information` when there is nothing extra to say.
80
+ - Save locked software versions in their layer-doc version tables when applicable.
81
+
82
+ ## Keeping Docs in Sync
83
+
84
+ Treat stale documentation like a failing test — fix it in the same branch as the change that made it wrong:
85
+
86
+ - A behavioural change updates the affected page **and** `CHANGELOG.md`.
87
+ - A structural change updates `.planning/architecture.md` (see **architecture-planning**).
88
+ - Missing or outdated docs are **Documentation debt** — log them via **tech-debt**, then track through **backlog-management**.
89
+
90
+ ## Commits & Branches
91
+
92
+ Documentation-only changes use the `docs` type (see **git-conventions**):
93
+
94
+ - Commit: `docs(<scope>): <imperative>` — e.g. `docs(api): clarify retry backoff`
95
+ - Branch: `docs/<short-kebab-description>`
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: git-conventions
3
+ description: Use when committing, creating branches, opening PRs, or managing git workflow, including worktrees for parallel agents. Covers Conventional Commits, branch naming tied to backlog IDs, one-change-per-branch discipline, worktree isolation scripts, versioning policy, and actions agents must never take.
4
+ ---
5
+
6
+ # Git Conventions
7
+
8
+ Enforces Conventional Commits and disciplined branching across all projects. Values marked *policy* come from `<root>/.planning/policy.yml`, generated on first use from best-practice defaults if the file doesn't exist (see **backlog-management**'s `scripts/generate-policy.sh`); the defaults stated below apply for any individual key still missing from an existing file.
9
+
10
+ ## Commit Format
11
+
12
+ ```
13
+ <type>(<scope>): <imperative verb>
14
+
15
+ Optional longer description explaining why, not what.
16
+ ```
17
+
18
+ **Types:** *policy* `git.commit_types`, default `feat`, `fix`, `chore`, `docs`, `refactor`, `test`. The set matches backlog item types so every item can have a matching branch.
19
+
20
+ **Examples:**
21
+ - `feat(auth): add JWT refresh rotation`
22
+ - `fix(search): resolve partial index corruption`
23
+ - `refactor(courses): extract pagination helper`
24
+ - `test(enrolment): cover duplicate enrolment path`
25
+ - `chore(deps): bump typescript to 5.1`
26
+ - `docs(api): clarify retry backoff behavior`
27
+
28
+ **Rules:**
29
+ - Imperative mood only: "add", not "added" or "adds"
30
+ - Lowercase after colon, no period at end
31
+ - Scope optional but preferred
32
+ - Breaking changes get `!` before colon: `feat!: remove legacy API`
33
+ - Backlog-only commits use scope `backlog`: `chore(backlog): claim 231`
34
+
35
+ ## Branch Naming
36
+
37
+ *policy* `git.branch_format`, default:
38
+
39
+ ```
40
+ <type>/<id>-<short-kebab-description>
41
+ ```
42
+
43
+ `<id>` is the backlog-management ID. It lets tooling join branches, PRs, and items without parsing titles.
44
+
45
+ **Examples:**
46
+ - `feat/231-user-authentication`
47
+ - `fix/244-cache-invalidation-race`
48
+ - `docs/250-api-endpoint-reference`
49
+ - `chore/backlog-sweep-2026-09-03-a1b2c3d` (routine branches carry a run ID instead)
50
+
51
+ Match the branch type to the commit type. Legacy branches without an ID are allowed only for work predating the backlog claim rule.
52
+
53
+ ## Pull Requests
54
+
55
+ - Body contains `Closes #<id>` (github-issues backend) or the item ID in the first line (markdown backend).
56
+ - Body sections: Summary, Verification (the merge-readiness rows with pass/fail), Backlog link.
57
+ - Label `needs-human` when the diff touches any *policy* `autonomous.require_human_review_if_touches` path. Such PRs are never merged by an agent.
58
+ - Draft PR as soon as the branch exists when working autonomously. It doubles as a visible claim.
59
+
60
+ ## Versioning
61
+
62
+ *policy* `versioning.bump`:
63
+ - `release-commit-only` (default): never bump `package.json` or `pyproject.toml` in a feature branch. Releases are cut in their own commit with `CHANGELOG.md`.
64
+ - `per-branch`: bump in the branch per **code-standards**.
65
+
66
+ ## Discipline
67
+
68
+ - **One logical change per branch.** No "WIP" or "misc" commits on shared branches. Squash or amend first.
69
+ - **Delete branches once merged.**
70
+ - **Never commit to protected branches directly.**
71
+ - **Forbidden without a human present:** force push, rewriting shared history, editing branch protection or rulesets, adding or upgrading a dependency, deleting or skipping a test. Mirrors *policy* `autonomous.forbidden`.
72
+
73
+ ## Worktrees (parallel work only)
74
+
75
+ Use a worktree only when agents work concurrently on the same repo. Sequential single-agent work uses a plain branch.
76
+
77
+ Use the project scripts, *policy* `worktrees.up` and `worktrees.down`:
78
+
79
+ ```bash
80
+ scripts/worktree-up.sh <id> <branch> # creates ../<repo>-<id>, allocates a port block,
81
+ # a DB name per id, writes .env, runs migrations
82
+ cd ../<repo>-<id> # commit + push from here
83
+ git push -u origin <branch>
84
+ scripts/worktree-down.sh <id> # drops DB, removes worktree, git worktree prune
85
+ ```
86
+
87
+ If the scripts do not exist, do not improvise: create a `chore` backlog item for them and run at most one worktree until they are merged. Raw fallback for that single worktree:
88
+
89
+ ```bash
90
+ git worktree add ../<repo>-<id> <branch>
91
+ git worktree remove ../<repo>-<id> # add --force to discard changes
92
+ git worktree prune
93
+ ```
94
+
95
+ **Rules:** no two worktrees share ports, DB names, or `.env`. Remove the worktree before declaring the task done. Run `git worktree list` to audit stragglers at the end of every run.
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: hatch-workflow
3
+ description: Workflow for working with hatch based VCC projects. Contains entrypoints for running tests, static analysis and building.
4
+ ---
5
+
6
+ # Hatch command agenda
7
+
8
+ This file lists the common `hatch` commands you can use in this repository to **test**, **type-check/lint/format**, and **build** artifacts like **wheels**, **docs**, and the **container**.
9
+
10
+ > Notes:
11
+ >
12
+ > - Commands are shown as you can run them from the repository root.
13
+ > - Some environments are matrix-based (e.g. `hatch-test`); you may see Hatch create env names like `hatch-test.py3.10-highest`.
14
+
15
+ ---
16
+
17
+ ## 1) Testing
18
+
19
+ ### Run all tests (default selection)
20
+
21
+ ```bash
22
+ hatch test
23
+ ```
24
+
25
+ ### Run all tests with coverage enabled (as configured)
26
+
27
+ ```bash
28
+ hatch test -c
29
+ ```
30
+
31
+ ### Run tests without xdist parallelism (useful for debugging / CI parity)
32
+
33
+ ```bash
34
+ hatch test -c -n0
35
+ ```
36
+
37
+ ### Run a specific test file (example)
38
+
39
+ ```bash
40
+ hatch test -c -n0 tests/unittest/test_constraint.py
41
+ ```
42
+
43
+ ---
44
+
45
+ ## 2) Static analysis (linting/formatting/docstring lint)
46
+
47
+ ### Lint and format with autofixes
48
+
49
+ ```bash
50
+ hatch fmt
51
+ ```
52
+
53
+ ### Docstring lint only
54
+
55
+ ```bash
56
+ hatch run hatch-static-analysis:lint-doc-string
57
+ ```
58
+
59
+ ### Lint (check) only
60
+
61
+ ```bash
62
+ hatch fmt --check --linter
63
+ ```
64
+
65
+ ### Lint with autofixes
66
+
67
+ ```bash
68
+ hatch fmt --linter
69
+ ```
70
+
71
+ ### Format check (no changes)
72
+
73
+ ```bash
74
+ hatch fmt --check --formatter
75
+ ```
76
+
77
+ ### Format apply (write changes)
78
+
79
+ ```bash
80
+ hatch fmt --formatter
81
+ ```
82
+
83
+ ---
84
+
85
+ ## 3) Type checking (mypy)
86
+
87
+ ### Run mypy (installs any missing stubs automatically)
88
+
89
+ ```bash
90
+ hatch run types:check
91
+ ```
92
+
93
+ ### Type-check a subset (example: only `src/vcc`)
94
+
95
+ ```bash
96
+ hatch run types:check src/vcc
97
+ ```
98
+
99
+ ---
100
+
101
+ ## 4) Build Python artifacts (wheel / sdist)
102
+
103
+ ### Build both sdist + wheel
104
+
105
+ ```bash
106
+ hatch build
107
+ ```
108
+
109
+ ### Clean build (recommended for release artifacts)
110
+
111
+ ```bash
112
+ hatch build -c
113
+ ```
114
+
115
+ ### Build only the wheel
116
+
117
+ ```bash
118
+ hatch build -c -t wheel
119
+ ```
120
+
121
+ ### Build only the sdist
122
+
123
+ ```bash
124
+ hatch build -c -t sdist
125
+ ```
126
+
127
+ ---
128
+
129
+ ## 5) Documentation (Sphinx)
130
+
131
+ ### Generate API docs (sphinx-apidoc) into `docs/code`
132
+
133
+ ```bash
134
+ hatch run docs:gen-api
135
+ ```
136
+
137
+ ### Build HTML documentation into `tmp/docs/build/html`
138
+
139
+ ```bash
140
+ hatch run docs:build
141
+ ```
142
+
143
+ ### Serve docs with live reload (sphinx-autobuild)
144
+
145
+ ```bash
146
+ hatch run docs:serve
147
+ ```