Harness maintenance pipeline

From Intense-Visions/harness-engineering · View interactive version

Harness maintenance pipeline is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > One on-demand entry point for project maintenance. Runs the checks that are actually overdue, triages what needs attention, and asks you — in plain text — which to fix. A thin wrapper over `harness

How to use this skill

Skill file

Harness Maintenance Pipeline

One on-demand entry point for project maintenance. Runs the checks that are actually overdue, triages what needs attention, and asks you — in plain text — which to fix. A thin wrapper over harness maintenance run; it owns no state of its own.

When to Use

What this skill does NOT do

Process

Phase 1: SWEEP — run the overdue report

  1. Run the report-mode sweep and capture stdout:

```bash

harness maintenance run --json

```

No flags = overdue, sweep-eligible tasks only, report mode (no PRs). Capture both stdout (the JSON report) and the exit code.

  1. Parse stdout as a ConsolidatedReport:

```ts

// shape emitted by the CLI (packages/cli/src/commands/maintenance-run.ts)

{

generatedAt: string;

mode: 'report' | 'fix';

fix: boolean;

exitCode: 0 | 1;

tasks: Array<{

taskId: string;

status: 'success' | 'failure' | 'skipped' | 'no-issues';

findings: number; // a COUNT — there is no per-finding severity

fixed: number;

prUrl: string | null;

summary: string; // 'clean' | ${n} finding(s) | error text

error?: string;

}>;

overdueNowCurrent: string[];

}

```

If capturing stdout is awkward, read the same object from .harness/maintenance/last-run-summary.json with the Read tool.

  1. Read the exit code: 0 = the sweep completed (findings are NOT failures); 1 = at least one check failed to execute; 2 = invalid invocation (a bug in how this skill called the CLI — fix the invocation, do not report it as a finding).
  1. If tasks is empty, tell the human "All maintenance is current — nothing overdue." and stop. Do not invent work.

Phase 2: TRIAGE — present a human-readable summary

There is no per-finding severity in the report, so triage by status then findings count (rows arrive pre-sorted failures-first, then findings-descending). Bucket the tasks:

Render a compact summary, for example:

Maintenance sweep (report mode) — 18 overdue tasks ran, exit 0

Failed to execute (1):
  stale-constraints   — check crashed: <summary>

Needs attention (3):
  dead-code           — 12 finding(s)
  doc-drift           —  4 finding(s)
  dependency-health   —  1 finding(s)

Skipped — couldn't run (1): license-audit (precondition not met)

Clean (13): project-health, hotspots, security, …

If overdueNowCurrent is non-empty, add a one-line footer: "N tasks were overdue and are now marked current."

Phase 3: FIX — ask in plain text, then opt in

  1. Ask the human in plain text, in your own reply. Do NOT use emit_interaction and do NOT use AskUserQuestion for this — those channels do not reliably reach the human (an emit_interaction ask collapses to "Called harness" and the human never sees the question). Write the question as ordinary text, listing the actionable task ids (the "Failed to execute" and "Needs attention" buckets) and asking which, if any, to fix. For example:

> These tasks have findings: dead-code (12), doc-drift (4), dependency-health (1). Which would you like me to fix? Reply with a comma-separated list of task ids, "all", or "none".

Then stop and wait for the human's reply. Do not proceed to a fix without an explicit answer.

  1. If the human picks tasks, re-invoke the CLI in fix mode, scoped to exactly those ids — and capture both streams separately:

```bash

harness maintenance run --only <comma,separated,ids> --fix --json

```

stdout stays a clean, parseable ConsolidatedReport (parse it as JSON, same shape as the sweep). Any honesty notice is written to stderr, NOT stdout — so capture stderr too (e.g. redirect to a separate file/buffer) and inspect it. If you only read stdout you will silently drop the notice; if you merge stderr into stdout you will break JSON.parse. Keep them apart: JSON ← stdout, notice ← stderr.

  1. Relay the result honestly. --fix threads fix mode through the real agent dispatcher: when a backend is configured for the default maintenance backend, the agent runs and commits its fixes directly to the worktree — there is no PR (prUrl stays null), and fixed is the real commit count. When no backend is configured (a plain checkout with no agent.backends in harness.orchestrator.md), --fix does not crash and does not pretend to work — it skips dispatch and prints this notice to stderr (which is why step 2 captures stderr separately):

> --fix: no agent backend configured for maintenance dispatch — dispatch was skipped and nothing was fixed. Configure agent.backends in harness.orchestrator.md (and maintenance.aiBackend), or run maintenance via the orchestrator.

Inspect the captured stderr for that notice and, if present, surface it verbatim. Report what the CLI actually did (the stdout report's fixed counts; prUrl is always null — there is no PR) — never claim a fix was applied or a PR opened when the report does not show one.

  1. If the human picks "none", stop. The report stands on its own.

Harness Integration

Gates

Success Criteria

Examples

Example: Milestone sweep with mixed results

The human invokes the skill before tagging a release.

  1. SWEEP: Run harness maintenance run --json. Exit code 0; tasks has 18 rows; overdueNowCurrent lists 18 ids.
  2. TRIAGE: Bucket the pre-sorted rows:

```

Maintenance sweep (report mode) — 18 overdue tasks ran, exit 0

Failed to execute (1):

stale-constraints — check crashed: cannot read .harness/constraints.json

Needs attention (3):

dead-code — 12 finding(s)

doc-drift — 4 finding(s)

dependency-health — 1 finding(s)

Clean (14): project-health, hotspots, security, …

18 tasks were overdue and are now marked current.

```

  1. FIX (plain-text ask): In the reply, write: "These tasks have findings: dead-code (12), doc-drift (4), dependency-health (1), plus stale-constraints failed to execute. Which would you like me to fix? Reply with a comma-separated list of task ids, \"all\", or \"none\"." Then stop and wait.
  2. The human replies dead-code,doc-drift. Run harness maintenance run --only dead-code,doc-drift --fix. With a backend configured, the agent dispatches and commits its fixes to the worktree — report the real fixed counts from the report (prUrl: null — there is no PR). If no backend is configured, the CLI prints to stderr: --fix: no agent backend configured for maintenance dispatch — dispatch was skipped and nothing was fixed. Configure agent.backends in harness.orchestrator.md (and maintenance.aiBackend), or run maintenance via the orchestrator. Relay that verbatim and report fixed: 0, prUrl: null — do not claim a fix or PR.

Example: Nothing overdue

Run harness maintenance run --json. On the nothing-overdue happy path stdout is still a parseable ConsolidatedReport whose tasks is an empty array (tasks: [], exitCode: 0) — NOT a plain All maintenance current. sentinel (that human string is emitted only on the non---json path). So JSON.parse(stdout) succeeds; read tasks.length === 0. Tell the human "All maintenance is current — nothing overdue." and stop. Do not invent work or run --fix.

Rationalizations to Reject

| Rationalization | Reality |

| ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| "I'll just run --fix directly to save a round-trip." | Report-first is the whole point. A surprise fix on an on-demand sweep is exactly the hazard this path avoids. |

| "I'll ask via emit_interaction so it's structured." | That ask never reaches the human — it collapses to "Called harness". Ask in plain text. |

| "The report shows findings, so I'll say I fixed them." | --fix only fixes when a backend dispatched; relay what the CLI reports (real fixed counts, or the no-backend skip notice). prUrl is always null. Do not overclaim. |

| "There's no severity field, so I'll assign my own." | Triage by the status + findings count the report actually provides. Do not fabricate a severity taxonomy. |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.