@raquezha/norpiv 0.0.2

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/README.md ADDED
@@ -0,0 +1,154 @@
1
+ # norpiv (Lean RPIV Workflow Engine)
2
+
3
+ A disciplined task execution lifecycle for the Pi coding agent designed to maximize accuracy, control, and traceability through a step-by-step Staff Engineer planning process.
4
+
5
+ ## πŸ” The Lifecycle
6
+
7
+ The RPIV engine splits task execution into separate, focused phases:
8
+
9
+ | Phase | Command | Purpose | Input / Output Files |
10
+ | :--- | :--- | :--- | :--- |
11
+ | **1. Ingest** | `/triage [source]:[id]` | Initial task verification and workspace setup. | Creates `.workflow/tasks/[source-id]/WORK.md` & `metadata.json` |
12
+ | **2. Scoping** | `/frame` | Author a clear, structured task brief. | Populates `WORK.md` βž” `[BRIEF]` section |
13
+ | **3. Interrogate**| `/grill-with-docs` | Stress-test brief against rules and docs. | Records decisions in `WORK.md` βž” `[GRILL]` |
14
+ | **4. Strategy** | `/plan` | Draft thin, independently testable slices. | Writes checkbox items in `WORK.md` βž” `[PLAN]` |
15
+ | **5. Coding** | `/implement` | Execute one approved plan slice (needs permission). | Modifies code; records updates in `WORK.md` βž” `[LOG]` |
16
+ | **6. Truth Test** | `/verify` | Run tests, lint, and verify quality. | Appends results to `[LOG]` |
17
+ | **7. Close** | `/sync` | Bridge local progress with external trackers. | Posts summary updates to Jira, GitHub, or GitLab |
18
+
19
+ Auxiliary hygiene:
20
+
21
+ | Command | Purpose | Input / Output Files |
22
+ | :--- | :--- | :--- |
23
+ | `/cleanup` | Declutter Git branches and completed task folders after work is merged/closed. | Prunes finished task folders & resets pointer when safe |
24
+
25
+ ---
26
+
27
+ ## πŸ›‘οΈ Critical Guardrails
28
+
29
+ - **Measure Twice, Cut Once**: Never implement code during scoping or planning. The agent will wait for an explicit `EXECUTE` statement before modifying files.
30
+ - **One Source of Truth**: All task state belongs in `.workflow/tasks/[source-id]/WORK.md`. Avoid creating separate `PROBLEM.md` or `PLAN.md` files.
31
+ - **Safe Branching**: Triage and planning happen on the main branch. Create the feature branch (`feat/*` or `fix/*`) only when starting `/implement`.
32
+
33
+ ## πŸ“¦ Install as a skill bundle
34
+
35
+ ### From GitHub with `npx skills add`
36
+
37
+ Best for trying or handing off RPIV skills without installing the full `nothing` setup:
38
+
39
+ ```bash
40
+ npx -y skills add raquezha/nothing --full-depth -g -a pi \
41
+ -s triage frame grill-with-docs plan implement verify sync cleanup update-docs \
42
+ -y
43
+ ```
44
+
45
+ ### From npm
46
+
47
+ ```bash
48
+ npm install -g @raquezha/norpiv
49
+ ```
50
+
51
+ Install the bundled skills for your agent runtime:
52
+
53
+ ```bash
54
+ # Pi default: ~/.pi/agent/skills/{triage,frame,plan,...}
55
+ norpiv-install
56
+
57
+ # Other adapters
58
+ norpiv-install --target claude
59
+ norpiv-install --target codex
60
+ norpiv-install --target all
61
+ ```
62
+
63
+ Targets:
64
+ - `pi` links skills into `~/.pi/agent/skills`.
65
+ - `claude` links skills into `~/.claude/skills`.
66
+ - `codex` installs the skill docs under `~/.codex/skills/norpiv` and writes an `AGENTS.md` adapter because Codex-style environments do not universally auto-load `SKILL.md` bundles.
67
+
68
+ `norpiv-install` also installs the shared helper scripts under a sibling `scripts/` directory so skill references like `../scripts/triage_helper.sh` resolve after installation.
69
+
70
+ ## πŸš€ Quick Start Example
71
+
72
+ 1. **Activate the RPIV Hat** from the full `nothing` setup:
73
+ ```bash
74
+ pi --rpiv
75
+ ```
76
+
77
+ If installed via `npx skills add` or `norpiv-install`, invoke the skills directly in your agent instead.
78
+
79
+ 2. **Triage an Issue**:
80
+ ```text
81
+ /triage github:45
82
+ ```
83
+
84
+ 3. **Frame the Work**:
85
+ ```text
86
+ /frame
87
+ ```
88
+
89
+ 4. **Verify Constraints**:
90
+ ```text
91
+ /grill-with-docs
92
+ ```
93
+
94
+ 5. **Write the Plan Slices**:
95
+ ```text
96
+ /plan
97
+ ```
98
+
99
+ 6. **Authorize Execution**:
100
+ Provide the agent explicit permission to implement:
101
+ ```text
102
+ EXECUTE
103
+ /implement
104
+ ```
105
+
106
+ 7. **Verify & Close**:
107
+ ```text
108
+ /verify
109
+ /sync
110
+ /cleanup
111
+ ```
112
+
113
+ ## 🧭 Shared helper scripts
114
+
115
+ The bundle includes helper scripts used by the workflow skills:
116
+
117
+ - `scripts/triage_helper.sh`
118
+ - `scripts/validate_active_task.sh`
119
+ - `scripts/reposcry-bootstrap.sh`
120
+ - `scripts/reposcry-task-context.sh`
121
+ - `scripts/reposcry-refresh.sh`
122
+
123
+ When skills are loaded directly from this package, relative references like `../scripts/...` resolve against the package root. When skills are installed with `norpiv-install`, the same layout is recreated under the target runtime.
124
+
125
+ ## πŸ”Ž Optional RepoScry integration
126
+
127
+ RepoScry is an optional repo-memory layer for RPIV. norpiv does **not** require it.
128
+
129
+ If `reposcry` is installed:
130
+
131
+ ```bash
132
+ ./scripts/reposcry-bootstrap.sh
133
+ ./scripts/reposcry-task-context.sh "fix dependency graph rebuild"
134
+ # edit code
135
+ ./scripts/reposcry-refresh.sh main
136
+ reposcry validate main HEAD
137
+ ```
138
+
139
+ Typical usage by phase:
140
+
141
+ - `/triage`: optionally seed `.reposcry/` with `scripts/reposcry-bootstrap.sh`
142
+ - `/frame`: optionally generate `.reposcry/AI_CONTEXT.md` with `scripts/reposcry-task-context.sh`
143
+ - `/grill-with-docs`: optionally use `reposcry query_graph`, `get_architecture_overview`, and `get_impact_radius`
144
+ - `/implement`: optionally run `scripts/reposcry-refresh.sh` after edit batches
145
+ - `/verify`: optionally add `reposcry validate main HEAD` and affected-flow output as extra evidence
146
+
147
+ If RepoScry is absent, the helpers no-op and RPIV continues with normal repo reading, grep, and tests.
148
+
149
+ RepoScry guardrails:
150
+
151
+ - `.reposcry/` is generated local cache and must not be committed.
152
+ - `scripts/reposcry-bootstrap.sh` automatically adds `.reposcry/` to the project `.gitignore` before initializing RepoScry.
153
+ - If `.reposcry/` is already tracked or staged, bootstrap stops and tells you to remove it from the index.
154
+ - `.reposcryignore` is indexing policy, not cache. Review and commit it when you want stable RepoScry behavior across machines.
@@ -0,0 +1,166 @@
1
+ #!/usr/bin/env node
2
+ const fs = require("node:fs");
3
+ const os = require("node:os");
4
+ const path = require("node:path");
5
+
6
+ const packageRoot = path.resolve(__dirname, "..");
7
+ const bundleName = "norpiv";
8
+ const sharedDirCandidates = ["scripts"];
9
+
10
+ function usage() {
11
+ console.log(`Usage: norpiv-install [--target pi|claude|codex|all] [--dest PATH] [--copy] [--force] [--dry-run]
12
+
13
+ Installs the bundled RPIV skill workflow and shared helper scripts for agent runtimes.
14
+
15
+ Targets:
16
+ pi Link skills into ~/.pi/agent/skills (default)
17
+ claude Link skills into ~/.claude/skills
18
+ codex Link skills into ~/.codex/skills/norpiv and generate an AGENTS.md adapter
19
+ all Install all targets
20
+
21
+ Options:
22
+ --dest PATH Override target skill directory
23
+ --copy Copy directories instead of symlinking
24
+ --force Replace existing paths instead of backing them up
25
+ --dry-run Print actions without changing files
26
+ --help Show this help`);
27
+ }
28
+
29
+ function parseArgs(argv) {
30
+ const opts = { target: "pi", dest: "", copy: false, force: false, dryRun: false };
31
+ for (let i = 0; i < argv.length; i++) {
32
+ const arg = argv[i];
33
+ if (arg === "--help" || arg === "-h") {
34
+ usage();
35
+ process.exit(0);
36
+ } else if (arg === "--target") {
37
+ opts.target = argv[++i] || "";
38
+ } else if (arg.startsWith("--target=")) {
39
+ opts.target = arg.slice("--target=".length);
40
+ } else if (arg === "--dest") {
41
+ opts.dest = argv[++i] || "";
42
+ } else if (arg.startsWith("--dest=")) {
43
+ opts.dest = arg.slice("--dest=".length);
44
+ } else if (arg === "--copy") {
45
+ opts.copy = true;
46
+ } else if (arg === "--force") {
47
+ opts.force = true;
48
+ } else if (arg === "--dry-run" || arg === "-n") {
49
+ opts.dryRun = true;
50
+ } else {
51
+ console.error(`Unknown argument: ${arg}`);
52
+ usage();
53
+ process.exit(2);
54
+ }
55
+ }
56
+ return opts;
57
+ }
58
+
59
+ function skillNames() {
60
+ return fs.readdirSync(packageRoot, { withFileTypes: true })
61
+ .filter((entry) => entry.isDirectory())
62
+ .map((entry) => entry.name)
63
+ .filter((name) => fs.existsSync(path.join(packageRoot, name, "SKILL.md")))
64
+ .sort();
65
+ }
66
+
67
+ function sharedDirNames() {
68
+ return sharedDirCandidates.filter((name) => fs.existsSync(path.join(packageRoot, name)));
69
+ }
70
+
71
+ function expandHome(p) {
72
+ if (!p) return p;
73
+ if (p === "~") return os.homedir();
74
+ if (p.startsWith("~/")) return path.join(os.homedir(), p.slice(2));
75
+ return p;
76
+ }
77
+
78
+ function targetRoot(target, dest) {
79
+ if (dest) return path.resolve(expandHome(dest));
80
+ if (target === "pi") return path.join(os.homedir(), ".pi", "agent", "skills");
81
+ if (target === "claude") return path.join(os.homedir(), ".claude", "skills");
82
+ if (target === "codex") return path.join(os.homedir(), ".codex", "skills", bundleName);
83
+ throw new Error(`Unsupported target: ${target}`);
84
+ }
85
+
86
+ function log(opts, message) {
87
+ console.log(`${opts.dryRun ? "[dry-run] " : ""}${message}`);
88
+ }
89
+
90
+ function rmrf(target, opts) {
91
+ if (opts.dryRun) return;
92
+ fs.rmSync(target, { recursive: true, force: true });
93
+ }
94
+
95
+ function cpdir(src, dest, opts) {
96
+ if (opts.dryRun) return;
97
+ fs.cpSync(src, dest, { recursive: true });
98
+ }
99
+
100
+ function symlinkDir(src, dest, opts) {
101
+ if (opts.dryRun) return;
102
+ fs.symlinkSync(src, dest, "dir");
103
+ }
104
+
105
+ function installOne(src, dest, opts) {
106
+ if (!fs.existsSync(src)) throw new Error(`Missing source: ${src}`);
107
+ log(opts, `install ${src} -> ${dest}${opts.copy ? " (copy)" : " (symlink)"}`);
108
+ if (!opts.dryRun) fs.mkdirSync(path.dirname(dest), { recursive: true });
109
+
110
+ if (fs.existsSync(dest)) {
111
+ const stat = fs.lstatSync(dest);
112
+ if (stat.isSymbolicLink()) {
113
+ const current = fs.readlinkSync(dest);
114
+ const resolved = path.resolve(path.dirname(dest), current);
115
+ if (!opts.copy && resolved === src) {
116
+ log(opts, `already linked ${dest}`);
117
+ return;
118
+ }
119
+ }
120
+ if (opts.force) {
121
+ log(opts, `remove existing ${dest}`);
122
+ rmrf(dest, opts);
123
+ } else {
124
+ const backup = `${dest}.backup.${Date.now()}`;
125
+ log(opts, `backup existing ${dest} -> ${backup}`);
126
+ if (!opts.dryRun) fs.renameSync(dest, backup);
127
+ }
128
+ }
129
+
130
+ if (opts.copy) cpdir(src, dest, opts);
131
+ else symlinkDir(src, dest, opts);
132
+ }
133
+
134
+ function writeCodexAdapter(root, names, sharedNames, opts) {
135
+ const adapter = path.join(root, "AGENTS.md");
136
+ const sharedLines = sharedNames.length
137
+ ? `\nShared helpers:\n\n${sharedNames.map((name) => `- ${name}/`).join("\n")}\n`
138
+ : "";
139
+ const body = `# norpiv RPIV skills for Codex\n\nCodex does not currently auto-load Pi/Claude SKILL.md bundles from npm.\n\nUse these installed skill instructions as a portable RPIV workflow reference:\n\n${names.map((name) => `- ${name}/SKILL.md`).join("\n")}\n${sharedLines}\nCore lifecycle: triage β†’ frame β†’ grill-with-docs β†’ plan β†’ implement β†’ verify β†’ sync β†’ cleanup.\n\nIf your Codex environment supports AGENTS.md discovery, copy or reference this file from your project.\n`;
140
+ log(opts, `write Codex adapter ${adapter}`);
141
+ if (!opts.dryRun) fs.writeFileSync(adapter, body);
142
+ }
143
+
144
+ function installTarget(target, opts) {
145
+ const root = targetRoot(target, opts.dest);
146
+ const names = skillNames();
147
+ const sharedNames = sharedDirNames();
148
+ if (!names.length) throw new Error(`No SKILL.md directories found in ${packageRoot}`);
149
+ if (!opts.dryRun) fs.mkdirSync(root, { recursive: true });
150
+ for (const name of names) {
151
+ const src = path.join(packageRoot, name);
152
+ const dest = path.join(root, name);
153
+ installOne(src, dest, opts);
154
+ }
155
+ for (const name of sharedNames) {
156
+ const src = path.join(packageRoot, name);
157
+ const dest = path.join(root, name);
158
+ installOne(src, dest, opts);
159
+ }
160
+ if (target === "codex") writeCodexAdapter(root, names, sharedNames, opts);
161
+ console.log(`Installed ${bundleName} skills for ${target} at ${root}`);
162
+ }
163
+
164
+ const opts = parseArgs(process.argv.slice(2));
165
+ const targets = opts.target === "all" ? ["pi", "claude", "codex"] : [opts.target];
166
+ for (const target of targets) installTarget(target, opts);
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: cleanup
3
+ description: "DIRECT EXECUTION: Immediately prunes local branches and task folders. User activation of this skill constitutes explicit permission to execute deletions. Do not ask for confirmation or offer dry runs unless requested. Reconciles stale Git refs and workflow artifacts."
4
+ ---
5
+
6
+ # Skill: cleanup (Durable Repo Hygiene)
7
+
8
+ > [!IMPORTANT]
9
+ > **LLM INSTRUCTION**: This skill is a DIRECT ACTION tool. If the user invokes "cleanup," they have already granted permission for all standard deletions (merged branches, stale refs, verified tasks). DO NOT offer a menu of options. DO NOT ask "Dry run or Execute?". Proceed directly to Step 1.
10
+
11
+ A durable, idempotent utility to synchronize the local filesystem and Git state with the project's "Definition of Done," regardless of whether the RPIV workflow is used.
12
+
13
+ ## Pre-conditions (Checkpoints)
14
+ - **Current Branch**: Should ideally be `main` or `master`.
15
+ - **Durable State Source**: `git branch` refs and (optionally) `.workflow/tasks/*/WORK.md`.
16
+
17
+ ## Workflow (Durable Steps)
18
+
19
+ ### Step 1: Remote Reconciliation
20
+ - `git remote update origin --prune`
21
+ - Identify branches deleted on remote.
22
+
23
+ ### Step 2: Analysis (General & Workflow)
24
+ Iterate through all local branches and `.workflow/tasks/*` folders:
25
+ - **STALE BRANCHES**: Local branches merged into `main` (safe to delete) or whose remote is gone.
26
+ - **VERIFIED TASKS**: `.workflow/tasks/*` where `WORK.md` state is `MERGED` or `CLOSED`.
27
+ - **ORPHANS**: Local branches with no remote and no task folder, or task folders with no branch.
28
+
29
+ ### Step 3: Atomic Execution
30
+ 1. **Branch Pruning**:
31
+ - Use `git branch -d` for merged branches.
32
+ - **Smart Merge Check**: If `-d` fails, check `git log main..[branch]`. If empty, the branch was squash-merged; use `git branch -D` quietly.
33
+ 2. **Artifact Cleanup**: If a `.workflow/tasks/` folder exists for a pruned branch, `rm -rf` it.
34
+ 3. **Active Task Reset**: Clear `.workflow/active_task.json` if it points to a deleted task.
35
+
36
+ ### Step 4: Durable Verification (Success Metrics)
37
+ - `git branch -a` must not contain deleted refs.
38
+ - `.workflow/tasks/` must not contain folders for deleted tasks.
39
+
40
+ ## Guardrails & Recovery
41
+ - **RESOLUTION OVER REPORTING**: Do not stall the user with "Ambiguous" lists or menus. If a status is unclear, the agent must check merge status (`git branch --merged` or `git log main..branch`) immediately and resolve it.
42
+ - **NO DRY RUNS BY DEFAULT**: Proceed directly to execution unless a dry run is explicitly requested.
43
+ - **MANDATORY SMART DELETE**: If `git branch -d` fails, the agent MUST check if the diff is empty. If empty (squash-merged), use `git branch -D` quietly.
44
+ - **TRUST THE USER**: If the user says "all done" or "clean it all," skip all safety checks and force-delete everything.
45
+ - **Dirty Tree**: If the working tree is dirty, `git stash` before branch switching and `git stash pop` as the final act.
46
+ - **Unmerged Work**: If a branch has no remote and contains unique commits, the agent **MUST** ask ONCE: "Branch [name] contains unmerged commits and has no remote. Force delete? (y/N)".
47
+
48
+ ## Output Contract
49
+ Return a concise "Durable State Report":
50
+ - **Cleaned**: List of (Task ID + Branch Name) successfully removed.
51
+ - **Skipped/Active**: List of tasks kept and why (e.g., "Contains unmerged commits").
52
+ - **Working Branch**: The branch left active (should be `main`).
53
+ - **Next step**: Ready for `/triage`.
package/frame/SKILL.md ADDED
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: frame
3
+ description: Define the task brief inside the active WORK.md. Use after /triage to convert issue data into a clear Problem or Proposal brief without creating separate PROBLEM.md or PRD.md files.
4
+ ---
5
+
6
+ # Skill: frame
7
+
8
+ Turn raw task context into the stable "what/why" brief.
9
+
10
+ ## Guardrails
11
+ - READ: `.workflow/active_task.json`, `.workflow/tasks/[active_task]/WORK.md`, and `.reposcry/AI_CONTEXT.md` when present.
12
+ - WRITE: `WORK.md` -> `[BRIEF]` section and append to `[LOG]` only; optional `.reposcry/AI_CONTEXT.md` when RepoScry is installed.
13
+ - NEVER: create `PROBLEM.md`, `PRD.md`, or extra planning files.
14
+ - NEVER: overwrite `[PLAN]` or `[GRILL]`.
15
+ - NEVER: ask whether to frame if the user invoked `/frame`; do it.
16
+
17
+ ## Workflow
18
+ 1. Read the active task and remote metadata.
19
+ 2. If RepoScry is available, run the bundled `../scripts/reposcry-task-context.sh "<task summary>"` helper to generate `.reposcry/AI_CONTEXT.md`, then use that file as supplemental repo context. The helper path must preserve RepoScry guardrails: `.reposcry/` ignored, cache never tracked, `.reposcryignore` treated as reviewable indexing policy. Continue normally when unavailable.
20
+ 3. Determine brief type:
21
+ - **Problem** for bugs, regressions, crashes, broken behavior.
22
+ - **Proposal** for features, enhancements, refactors, new behavior.
23
+ 4. Create or replace only the `[BRIEF]` section with:
24
+ - type and source id
25
+ - current understanding
26
+ - desired outcome
27
+ - constraints / non-goals
28
+ - acceptance hints if available
29
+ 5. Keep the brief concise and reviewable.
30
+ 6. **Log Activity**: Append a timestamped summary of the framing/re-framing to `[LOG]` (Format: `YYYY-MM-DD hh:mm AM/PM`). Include why the change was made if it is a pivot.
31
+ 7. End by recommending `/grill-with-docs`.
32
+
33
+ ## Output contract
34
+ End with:
35
+ - **Brief type**: Problem / Proposal
36
+ - **Updated section**: `[BRIEF]`
37
+ - **Open questions**: only if blocking
38
+ - **Next step**: `/grill-with-docs`
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: grill-with-docs
3
+ description: Stress-test the active WORK.md brief against docs, code, and domain language. Use after /frame before planning to clarify assumptions and update durable docs only when decisions are stable.
4
+ ---
5
+
6
+ # Skill: grill-with-docs
7
+
8
+ Challenge the brief before planning. This replaces passive ubiquitous-language collection with active clarification.
9
+
10
+ ## Guardrails
11
+ - READ: `.workflow/active_task.json`, active `WORK.md` `[BRIEF]`, `CONTEXT.md`, relevant `docs/agents/*`, and `.reposcry/AI_CONTEXT.md` when present.
12
+ - WRITE: `WORK.md` -> append to `[GRILL]` and `[LOG]` only; durable docs only when a stable rule is confirmed.
13
+ - NEVER: edit `[BRIEF]` silently; propose brief changes if contradictions are found.
14
+ - NEVER: plan or implement during grilling.
15
+ - NEVER: ask questions the codebase can answer; inspect first.
16
+
17
+ ## Workflow
18
+ 1. **Context Loading**: Read the active brief, `CONTEXT.md`, relevant `docs/agents/*`, and `.reposcry/AI_CONTEXT.md` when available.
19
+ 2. **Investigation & Trace**:
20
+ - Locate the files/lines mentioned in the brief.
21
+ - Trace the data flow related to the problem/proposal.
22
+ - Search for "Impact Surface": Who else uses or depends on these components?
23
+ 3. **Optional RepoScry graph pass**: if `reposcry` is available, use it to ground architecture and blast radius. Before relying on it, ensure the bundled bootstrap/context helper has kept `.reposcry/` ignored and untracked. Use commands such as:
24
+ - `reposcry --repo . get_architecture_overview --format json`
25
+ - `reposcry --repo . query_graph "callers_of <symbol>"`
26
+ - `reposcry --repo . query_graph "tests_for <symbol>"`
27
+ - `reposcry --repo . get_impact_radius <symbol> --depth 4`
28
+ Proceed normally when RepoScry is absent.
29
+ 4. **Cross-check**: Compare findings against docs, ADRs, and repo patterns.
30
+ 5. **Relentless Interview**:
31
+ - Ask one question at a time to resolve contradictions or clarify ambiguity.
32
+ - Challenge the brief if the code behaves differently than described.
33
+ 6. **Log Evidence**: Append resolved decisions, technical findings, edge cases, and constraints to `[GRILL]`.
34
+ 7. **Log Activity**: Append a timestamped summary of the grilling session to `[LOG]` (Format: `YYYY-MM-DD hh:mm AM/PM`).
35
+ 8. **Context Curation**: If a durable term/rule emerges, propose or apply a concise `docs/agents/*` update.
36
+
37
+ ## Output contract
38
+ End with:
39
+ - **Investigation Summary**: (Technical findings & Impact Surface)
40
+ - **Resolved decisions**
41
+ - **Remaining blockers**
42
+ - **Docs updates proposed/applied**
43
+ - **Next step**: `/plan` only when the brief is stable and code reality is verified.
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: implement
3
+ description: Implement the next approved vertical slice from the active WORK.md and prepare a Draft PR/MR. Use when the plan is approved and the user explicitly asks to implement.
4
+ ---
5
+
6
+ # Skill: implement
7
+
8
+ Execute one functional vertical slice and hand it to the human for review.
9
+
10
+ ## Guardrails
11
+ - READ: `.workflow/active_task.json` then active `WORK.md` `[PLAN]`, `[BRIEF]`, and relevant `[LOG]` evidence.
12
+ - WRITE: code changes and `WORK.md` -> append to `[LOG]` only; optional `.reposcry/` cache refresh when RepoScry is installed.
13
+ - NEVER: edit `[BRIEF]` or `[GRILL]`.
14
+ - NEVER: implement without explicit user instruction.
15
+ - NEVER: commit a Jira-tracked task with a Jira-less subject; if the active task source is `jira`, the commit subject MUST include the Jira key from `.workflow/active_task.json` (e.g. `fix(PROJ-123): ...`).
16
+ - NEVER: hide the Jira key only in the commit body/footer when the task is Jira-tracked; the subject itself must carry the key.
17
+ - NEVER: add `Signed-off-by`; only the human can certify DCO.
18
+ - NEVER: freestyle PR/MR descriptions; use the Draft PR/MR body contract below.
19
+
20
+ ## Workflow
21
+ 1. Identify the first approved unchecked slice in `[PLAN]`.
22
+ 2. Move tracked task to **In Progress** only when implementation actually starts.
23
+ 3. **Mandatory Branch Check**: You MUST run the branch enforcement script before modifying any code.
24
+ - Use the absolute path if possible: `<skill_location>/scripts/enforce-branch.sh`.
25
+ - This script prevents accidental implementation on `main`/`master`.
26
+ - If the script switches branches, you must update the `[META]` section of `WORK.md` to reflect the new branch name.
27
+ - If the script fails, STOP and ask the human for help. Do not proceed with code changes.
28
+ 4. Optional RepoScry blast-radius pass: if `reposcry` is available, inspect impact before wide edits (`reposcry --repo . get_impact_radius <symbol> --depth 4` or related graph queries). Continue normally when RepoScry is absent.
29
+ 5. Implement test-first where practical; otherwise document why not in `[LOG]`.
30
+ 6. After each edit batch, if the bundled `../scripts/reposcry-refresh.sh` helper is present and `reposcry-update` is installed, run it. RepoScry refresh failure should not block implementation. Never stage or commit `.reposcry/`; it is generated cache. `.reposcryignore` may be committed only after review as indexing policy.
31
+ 7. Run the slice verification command and available quality gates.
32
+ 8. Commit with a Conventional Commit header and `Assisted-by: [AGENT]:[MODEL] [tools]` footer (populating the agent name and model ID from the current session context).
33
+ - For Jira-tracked tasks, the header MUST include the Jira key in the scope position: `fix(PROJ-123): ...` or `feat(PROJ-123): ...`.
34
+ - If release-note tooling also needs the key in parsed text, add `Refs: PROJ-123` in the body/footer as well.
35
+ 9. Push and open a Draft PR/MR with `gh` or `glab` when a remote exists.
36
+ - For Jira-tracked tasks, the PR/MR title MUST also include the Jira key and should mirror the commit subject.
37
+ 10. Use a temporary body file (`--body-file` or API equivalent) for PR/MR descriptions to avoid shell quoting and markdown escaping bugs.
38
+ 11. Append summary, commit hash, and PR/MR link to `[LOG]` (Format: `YYYY-MM-DD hh:mm AM/PM`).
39
+
40
+ ## Draft PR/MR body contract
41
+
42
+ Generate the Draft PR/MR body from the active `WORK.md`, implemented slice, commit(s), and verification evidence. If a section has no evidence yet, say so explicitly; do not omit the section.
43
+
44
+ Use this exact section order:
45
+
46
+ ```md
47
+ ## Summary
48
+ - <one to three bullets describing what changed and why>
49
+
50
+ ## Scope
51
+ - <files/areas changed>
52
+ - <notable behavior or workflow changes>
53
+
54
+ ## Verification
55
+ - [x] <command or check that passed>
56
+ - [ ] <manual check still needed, if any>
57
+
58
+ ## Risk / Rollback
59
+ - Risk: <main regression or operational risk, or "Low" with reason>
60
+ - Rollback: <revert commit, disable feature, or restore previous behavior>
61
+
62
+ ## RPIV Task
63
+ - Task: `<source>:<id>`
64
+ - Slice: <slice name>
65
+ - Branch: `<branch>`
66
+
67
+ ## Human Review Checklist
68
+ - [ ] Review changed files for repo conventions.
69
+ - [ ] Confirm verification evidence is sufficient.
70
+ - [ ] Confirm no secrets, local-only paths, or scratch artifacts are included.
71
+ ```
72
+
73
+ ### PR/MR body rules
74
+ - Keep the body concise and reviewer-focused.
75
+ - Prefer bullets over paragraphs.
76
+ - Include verification commands exactly as run.
77
+ - Include failed or skipped verification as explicit unchecked items with reasons.
78
+ - Include known risks instead of saying β€œnone” unless risk is genuinely low and explained.
79
+ - Include the RPIV task id and slice name so review can trace back to `WORK.md`.
80
+ - Do not include private notes, secrets, environment variable values, or local scratch paths.
81
+
82
+ ### GitHub example
83
+ ```bash
84
+ body_file=$(mktemp)
85
+ cat > "$body_file" <<'EOF'
86
+ ## Summary
87
+ - ...
88
+
89
+ ## Scope
90
+ - ...
91
+
92
+ ## Verification
93
+ - [x] ...
94
+
95
+ ## Risk / Rollback
96
+ - Risk: ...
97
+ - Rollback: ...
98
+
99
+ ## RPIV Task
100
+ - Task: `local:setup-v2`
101
+ - Slice: Slice 1 β€” Idempotent `/triage` helper
102
+ - Branch: `feat/setup-v2`
103
+
104
+ ## Human Review Checklist
105
+ - [ ] Review changed files for repo conventions.
106
+ - [ ] Confirm verification evidence is sufficient.
107
+ - [ ] Confirm no secrets, local-only paths, or scratch artifacts are included.
108
+ EOF
109
+
110
+ gh pr create --draft --title "<title>" --body-file "$body_file"
111
+ ```
112
+
113
+ ### GitLab example
114
+ ```bash
115
+ body_file=$(mktemp)
116
+ cat > "$body_file" <<'EOF'
117
+ ## Summary
118
+ - ...
119
+ EOF
120
+
121
+ glab mr create --draft --title "<title>" --description "$(cat "$body_file")"
122
+ ```
123
+
124
+ Prefer true body-file flags when available. If the CLI only supports a string description, write the body to a temp file first and read it from there to avoid inline shell quoting mistakes.
125
+
126
+ ## Output contract
127
+ End with:
128
+ - **Slice implemented**
129
+ - **Verification run**
130
+ - **Commit**
131
+ - **Draft PR/MR**
132
+ - **Human review required**