> ## Documentation Index
> Fetch the complete documentation index at: https://smithers.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# context-doctor

> Run deterministic checks over a context contract and report missing goals, inputs, verification, approvals, and report specs.

`context-doctor` is an archived example, not installed by `init`; copy it from `examples/init-pack/` with its dependency closure, or ask `create-workflow` for an equivalent, then run it below.

`context-doctor` lints a context contract: it deterministically parses the
contract JSON and runs seven structural checks (goal, output spec, acceptance
criteria, blocking-criteria verification, required-input sources, side-effect
approvals, report spec), then an agent suggests a fix for each finding. Reach
for it before handing a contract to an agent, catching missing inputs, ungated
side effects, or absent acceptance criteria.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bunx smithers-orchestrator workflow run context-doctor \
  --input '{"contract":"{\"goal\":\"Add CSP headers\",\"acceptanceCriteria\":[{\"text\":\"headers present\",\"blocking\":true,\"verification\":\"curl -I\"}],\"inputs\":[{\"name\":\"repo\",\"required\":true,\"source\":\"arg\"}],\"sideEffects\":[{\"name\":\"deploy\",\"approval\":true}],\"outputSpec\":\"patch\",\"reportSpec\":\"summary\"}"}'
```

## Stages

1. **check**: deterministic (no agent), `JSON.parse` the contract and run the structural checks, returning `{ issues, summary, score }`.
2. **advise**: an agent reads the diagnosis and writes one `{ check, fix }` pair per non-ok issue (`check` is the check id being resolved), ordered error → warning → info.

## Checks

* **hasGoal**: `goal` is non-empty.
* **hasOutputSpec**: `outputSpec` (or `output`) describes the produced artifact.
* **hasAcceptanceCriteria**: at least one acceptance criterion is listed.
* **allBlockingCriteriaHaveVerification**: every `blocking` criterion names a `verification`. Plain-string criteria warn: a string can't declare `blocking` or `verification`, so use `{text, blocking, verification}` objects.
* **allRequiredInputsHaveSource**: every `required` input declares a `source`.
* **allSideEffectsHaveApproval**: every `sideEffects` entry is gated by an `approval`. Plain-string entries count as unguarded; use `{name, approval}` objects.
* **reportSpecExists**: `reportSpec` describes how results are reported.

## Inputs

| Input      | Type                                | Default |
| ---------- | ----------------------------------- | ------- |
| `contract` | string (JSON of a context contract) | `"{}"`  |

## Monitor it

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bunx smithers-orchestrator workflow run context-doctor --input '{"contract":"…"}' -d   # detach
bunx smithers-orchestrator ps                                                          # active / paused / recent
bunx smithers-orchestrator logs RUN_ID -f                                             # follow events
bunx smithers-orchestrator output RUN_ID --node check                                 # inspect the deterministic diagnosis
```
