Metadata-Version: 2.4
Name: antemortem
Version: 0.11.0
Summary: CLI for pre-diff risk classification with schema validation and disk-verified citations.
Project-URL: Homepage, https://github.com/hibou04-ops/antemortem-cli
Project-URL: Source, https://github.com/hibou04-ops/antemortem-cli
Project-URL: Repository, https://github.com/hibou04-ops/antemortem-cli
Project-URL: Documentation, https://github.com/hibou04-ops/antemortem-cli#readme
Project-URL: Changelog, https://github.com/hibou04-ops/antemortem-cli/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/hibou04-ops/antemortem-cli/issues
Project-URL: Methodology, https://github.com/hibou04-ops/Antemortem
Author-email: Kyunghoon Gwak <hibouaile04@gmail.com>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for describing the origin of the Work and
              reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may accept and charge a
              fee for, or offer to accept, a warranty, support, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright 2026 hibou04-ops
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: AUTHORS.md
License-File: LICENSE
License-File: NOTICE
Keywords: antemortem,anthropic,claude,code-review,pre-mortem,reconnaissance,risk-classification
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.11
Requires-Dist: anthropic>=0.40.0
Requires-Dist: google-genai>=1.0.0
Requires-Dist: openai>=1.50.0
Requires-Dist: pydantic>=2.6.0
Requires-Dist: python-frontmatter>=1.1.0
Requires-Dist: typer>=0.12.0
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.40.0; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == 'dev'
Requires-Dist: hatchling>=1.25.0; extra == 'dev'
Requires-Dist: mcp>=1.0.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: twine>=5.0.0; extra == 'dev'
Provides-Extra: gemini
Requires-Dist: google-genai>=1.0.0; extra == 'gemini'
Provides-Extra: mcp
Requires-Dist: mcp>=1.0.0; extra == 'mcp'
Provides-Extra: ollama
Requires-Dist: ollama>=0.3.0; extra == 'ollama'
Provides-Extra: openai
Requires-Dist: openai>=1.50.0; extra == 'openai'
Description-Content-Type: text/markdown

# antemortem — does your AI agent actually read your code, or just sound like it?

**Your coding agent wrote a plan and swears it's safe against your repo. Prove it.**
`antemortem` makes the AI cite a real `file:line` for every claim, then **machine-checks each citation against the bytes on your disk — offline.** A fabricated citation makes the check fail. No prose to trust. A deterministic PASS / FAIL, with a hard **fabrication rate** number you can gate CI on.

[![CI](https://github.com/hibou04-ops/antemortem-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/hibou04-ops/antemortem-cli/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/antemortem?color=blue&label=pypi&cacheSeconds=3600)](https://pypi.org/project/antemortem/)
[![Python](https://img.shields.io/pypi/pyversions/antemortem?cacheSeconds=3600)](https://pypi.org/project/antemortem/)
[![License](https://img.shields.io/pypi/l/antemortem?color=blue&cacheSeconds=3600)](LICENSE)
[![MCP server](https://img.shields.io/badge/MCP-server-blueviolet?cacheSeconds=3600)](#1-the-hero-your-agent-runs-it-on-itself-mcp--ci)

> **AI code review · LLM hallucination check · verify AI citations · pre-merge AI plan review · AI agent guardrails · Claude Code / Cursor / Copilot hook · MCP server · GitHub Action**

README family: [English](README.md) · [한국어](README_KR.md) · [Easy start](EASY_README.md) · [쉬운 한국어](EASY_README_KR.md) · Deep docs: [`docs/`](docs/) · [Claim ledger](docs/claim_ledger.md) ([한국어](docs/claim_ledger_kr.md))

```bash
pip install antemortem
```

## Quick start

```bash
pip install antemortem
export ANTHROPIC_API_KEY=...   # or OPENAI_API_KEY / GEMINI_API_KEY; Ollama needs no key

antemortem init   my-feature                          # scaffold the recon doc
antemortem doctor my-feature.md --repo .              # preflight: no API call
antemortem run    my-feature.md --repo .              # one call → classifications + citations
antemortem lint   my-feature.md --repo .              # re-verify every citation offline
antemortem gate   my-feature.md --repo .              # enforce the decision policy in CI
```

No key to try it? Jump to [Try it in 30 seconds](#try-it-in-30-seconds--no-api-key) for the offline demo.

## Table of Contents

- [The problem, in one screen](#the-problem-in-one-screen)
- [The headline: a hard fabrication-rate number](#the-headline-a-hard-fabrication-rate-number)
- [The hero: your agent runs it on itself (MCP + CI)](#1-the-hero-your-agent-runs-it-on-itself-mcp--ci)
- [Try it in 30 seconds — no API key](#try-it-in-30-seconds--no-api-key)
- [Why this works — the two ideas](#why-this-works--the-two-ideas-this-is-the-word-antemortem)
- [The full loop (with an API key)](#the-full-loop-with-an-api-key)
- [Multi-provider — including local, keyless Ollama](#multi-provider--including-local-keyless-ollama)
- [When NOT to use it](#when-not-to-use-it)

---

## The problem, in one screen

In 2026 your agent — Claude Code, Cursor, Copilot, Aider — writes the plan and the patch, then tells you, confidently, that it's safe against your existing code. You have **no fast way to check whether it actually read your repo or just hallucinated a reassuring answer.**

LLMs are fluent. Fluency is not evidence. An agent will cite `auth/middleware.py:48` for a claim that line 48 doesn't support — or for a line that doesn't exist. You find out at runtime.

**antemortem is the gate that catches that.** It forces the model to ground every verdict in a real `file:line`, then re-reads each cited line **offline against the disk**. The output isn't prose you have to believe — it's a machine-checkable **PASS / FAIL** plus a **fabrication rate**:

```text
trap t1: "refresh path leaves the old session cookie live"
  model says: REAL   cite auth/middleware.py:45-52
  antemortem lint → lines 45-52 exist, evidence hash matches disk   ✓ VERIFIED

trap t2: "race on concurrent refresh"
  model says: GHOST  cite auth/token.py:72
  antemortem lint → file has 60 lines; line 72 does not exist       ✗ FABRICATED → exit 1
```

If the agent invented a citation, the second case is exactly what you see. The lie does not merge.

---

## The headline: a hard fabrication-rate number

`antemortem metrics` answers exactly one question — *is the model citing real evidence?* — and prints the number that proves it. Point it at a run artifact; it reports verified vs fabricated vs unresolved citations and a **fabrication rate**, then fails CI when that rate is too high:

```bash
# How often did the model hallucinate its own evidence?
antemortem metrics antemortem/feat.json --repo .
#   Citations: verified=7, fabricated=1, unresolved=2, cited=8, total=10
#   Fabrication rate: 12.5% of cited
#   Status: FAIL (fabricated citations present)

# Zero tolerance in CI — any fabricated citation fails the job (exit 4):
antemortem metrics antemortem/feat.json --repo . --fail-over 0 --format json
```

`--format json` emits a stable `antemortem-citation-metrics-v1` summary; `--fail-over <rate>` exits `4` (policy gate) when `fabricated / cited` exceeds your threshold. This is the LLM-hallucination check, reduced to one auditable percentage.

Need a shareable artifact instead of a console line? `antemortem report` renders the same run into a single-file Markdown or HTML scorecard — decision verdict, per-trap table, citation-verification status — self-contained (HTML inlines its own CSS) so you can attach it to a PR or publish it as a CI artifact:

```bash
antemortem report antemortem/feat.json --repo . --format html --out scorecard.html
```

---

## 1. The hero: your agent runs it on itself (MCP + CI)

### Wire it into your coding agent (MCP server)

`antemortem-mcp` is a [Model Context Protocol](https://modelcontextprotocol.io) server. Plug it into Claude Code (or any MCP client) and your agent gains three tools it can call on its **own** output before asking you to merge:

| MCP tool | What the agent does with it |
|---|---|
| `scaffold` | Opens a recon doc for the change it's about to make. |
| `run` | Classifies each risk against the **actual repo files** as `REAL` / `GHOST` / `NEW` / `UNRESOLVED`, every non-`UNRESOLVED` verdict carrying a `file:line` citation. |
| `lint` | **Re-verifies those citations offline against the disk.** Zero LLM calls. Catches the model hallucinating its own evidence. |

The MCP server exposes exactly these three tools (`scaffold`, `run`, `lint`). The CI-facing surface — gating, fabrication metrics, scorecards — runs as the CLI in your pipeline, not as MCP tools. One paste into `.mcp.json` (or `claude_desktop_config.json` for the desktop client):

```jsonc
{
  "mcpServers": {
    "antemortem": {
      "command": "python",
      "args": ["-m", "antemortem.mcp"],
      "env": { "ANTHROPIC_API_KEY": "sk-ant-..." }
    }
  }
}
```

```bash
pip install "antemortem[mcp]"
```

The server speaks stdio by default — what Claude Code expects. Need network transport? `python -m antemortem.mcp --http`. Confine the agent's filesystem reach with `ANTEMORTEM_WORKSPACE_ROOT`, so every path it passes must resolve under one root. Now the agent can't just *say* "I checked the repo" — it produces an artifact whose every claim points at a line on disk, and `lint` decides whether that line backs the claim. **Self-review you can audit, not self-review you have to trust.** Full setup in [`docs/MCP.md`](docs/MCP.md).

### Block the PR in CI — one `uses:` step

Because antemortem ships a composite **GitHub Action** (`action.yml` at the repo root), the whole gate is one step — no glue, no install script. It installs antemortem from PyPI, runs the offline `lint` + decision gate, and fails the job on a blocked decision or a fabricated citation:

```yaml
# .github/workflows/antemortem.yml
name: antemortem gate
on: [pull_request]
jobs:
  recon-gate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: hibou04-ops/antemortem-cli@v0.11.0
        with:
          document: antemortem/my-feature.md
          repo: .
          allow: SAFE_TO_PROCEED,PROCEED_WITH_GUARDS
```

The action's JSON summary (`schema: antemortem-gate-v1`) carries the verdict, decision, and fabricated-citation metrics, exposed as a step `summary` output for downstream steps. Prefer the raw CLI? The same gate is one shell line:

```yaml
      - run: pip install antemortem
      # Re-verify every citation against this checkout, then enforce the policy.
      - run: antemortem gate antemortem/my-feature.md --repo .
```

`antemortem gate` runs the offline `lint` first (citations + evidence hashes against disk), then enforces a **decision allowlist**. The four labels are deterministic — same artifact in, same verdict out, no model call:

| Decision | Meaning |
|---|---|
| `SAFE_TO_PROCEED` | No real risks remain. |
| `PROCEED_WITH_GUARDS` | Real risks exist, each has a remediation. |
| `NEEDS_MORE_EVIDENCE` | Too much unresolved, or citations don't hold. |
| `DO_NOT_PROCEED` | A high-severity risk with no mitigation. |

Default allowlist is `SAFE_TO_PROCEED,PROCEED_WITH_GUARDS`. Exit codes are stable: `0` pass · `1` validation/citation failure · `2` usage error · `3` provider failure · `4` policy gate blocked. CI branches on the exit code — it never reads prose. Full reference in [`docs/GITHUB_ACTION.md`](docs/GITHUB_ACTION.md).

### Gate the patch the agent *actually* wrote

Don't trust a hand-listed file scope — derive it from the diff. `antemortem run --diff <ref>` reads the changed files straight from a git diff and audits exactly that patch:

```bash
antemortem run antemortem/my-feature.md --repo . --diff origin/main
antemortem gate antemortem/my-feature.md --repo . --format json
```

`--diff` accepts `staged`, `working`, or any git ref/range (`HEAD~1`, `origin/main`, `a..b`); the changed files are merged into the recon scope. So the gate covers the agent's *real* changes, not just the ones it chose to mention.

---

## "Just ask the agent to review it" — and why that loses

The free competitor is zero-friction: tell your agent *"review this plan against the repo."* It will. It'll sound thorough. An AI grading its own homework with no answer key writes whatever sounds right. Here's the gap antemortem closes — and how it differs from a post-diff PR-review bot (CodeRabbit, Copilot review, etc.):

| | Ask the agent to review it | PR-review bots (CodeRabbit, etc.) | **antemortem** |
|---|:-:|:-:|:-:|
| When it runs | chat, ad-hoc | **after** the diff exists | **before** the diff — on the plan |
| Who frames the risk list | the agent (rubber-stamps) | the bot | **you do, before it sees code** |
| Every claim cites `file:line` | no | sometimes | **yes (schema-enforced)** |
| Citations re-verified on disk | no | no | **yes (`lint`, offline, deterministic)** |
| Catches a *fabricated* citation | no | no | **yes (the run fails)** |
| Hard fabrication-rate number | no | no | **yes (`metrics`, gate on it)** |
| Machine pass/fail a PR can gate on | no | partial | **yes (stable exit codes)** |
| Persistent, re-checkable artifact | no (a chat message) | review comments | **yes (markdown + JSON + scorecard)** |

That answer key is `antemortem` — checked by a program, not by the agent's own confidence.

---

## Try it in 30 seconds — no API key

The bundled demo replays a real recon from stored output, so **no key and no network** are needed. The `lint` at the end is the live offline check:

```bash
git clone https://github.com/hibou04-ops/antemortem-cli.git
cd antemortem-cli && pip install -e ".[mcp]"

# 4 traps → REAL / GHOST / NEW / UNRESOLVED → a decision (pre-recorded, offline)
PYTHONIOENCODING=utf-8 python examples/demo_replay.py

# now machine-verify every file:line and evidence hash against disk
antemortem lint examples/demo_antemortem.md --repo .

# ...and reduce it to one fabrication-rate number
antemortem metrics examples/demo_antemortem.json --repo .
```

`lint` exits `0` if every citation checks out on disk, `1` if any is fabricated or stale. That single exit code is the whole product: a deterministic, offline answer to *"did the AI lie about the codebase?"*

---

## Why this works — the two ideas (this is the word "antemortem")

A *post*-mortem asks why something already failed. **An antemortem runs the autopsy before the patient — your change — is even born:** it interrogates an AI's plan against the real code *before* the first keystroke. That word is the whole method, and two mechanisms make the review impossible to rubber-stamp:

1. **Anchoring defense.** *You* enumerate the risks ("traps") **before the model sees the code.** The model never frames your risk list, so it can't quietly agree with its own framing and call it review. It has to take a position on *your* hypotheses, against *your* file scope.
2. **Hallucination-proof review.** Every non-`UNRESOLVED` verdict is a machine-verifiable disk citation, and a **deterministic offline lint fails the run if a citation is fabricated.** When the artifact carries an `evidence_hash` or snippet, lint also confirms the cited *text* hasn't drifted. The model's confidence is irrelevant — only the disk decides.

| Label | Meaning | Evidence required |
|---|---|---|
| `REAL` | The code confirms the risk. | `file:line` where it surfaces |
| `GHOST` | The code disproves it (already handled). | `file:line` that contradicts it |
| `NEW` | A risk the model found that you missed. | `file:line` of the raising code |
| `UNRESOLVED` | No evidence either way. Honest, not a failure. | none (explanation required) |

No mainstream tool turns LLM reconnaissance into a lint-able, gate-able CI artifact like this. The full trust model — what it verifies and what it deliberately does not — is in [`docs/trust_model.md`](docs/trust_model.md) ([한국어](docs/trust_model_kr.md)).

---

## The full loop (with an API key)

```bash
export ANTHROPIC_API_KEY=...   # or OPENAI_API_KEY / GEMINI_API_KEY / GOOGLE_API_KEY; Ollama needs no key

antemortem init    my-feature                          # scaffold the recon doc
#   edit antemortem/my-feature.md:
#     § Spec   — the change   § Traps — YOUR risk hypotheses   § Files — the scope
antemortem doctor  antemortem/my-feature.md --repo .   # preflight: no API call
antemortem run     antemortem/my-feature.md --repo .   # one call → classifications + citations
antemortem lint    antemortem/my-feature.md --repo .   # re-verify every citation offline
antemortem gate    antemortem/my-feature.md --repo .   # enforce the decision policy
antemortem metrics antemortem/my-feature.json --repo . # fabrication-rate number
antemortem report  antemortem/my-feature.json --repo . --format html --out scorecard.html
```

That is the full command surface — **9 commands**: `init`, `doctor`, `run`, `lint`, `evidence`, `gate`, `eval`, `metrics`, `report`. `evidence` fills/checks evidence hashes (no provider call), `eval` scores offline golden cases, and `--strict-evidence` on `lint` requires the cited *text*, not just the line range, to be unchanged.

---

## Multi-provider — including local, keyless Ollama

The discipline is vendor-neutral; the LLM is the only pluggable seam. First-class adapters ship for **`anthropic`, `openai`, `gemini`, and `ollama`** (local, keyless inference via a running daemon), plus any **OpenAI-compatible endpoint** (Azure, Groq, Together, OpenRouter) via `--provider openai --base-url <url>`:

```bash
antemortem run antemortem/feat.md --repo . --provider ollama          # local, no API key
antemortem run antemortem/feat.md --repo . --provider openai --base-url https://...  # compatible endpoint
```

Every adapter uses the provider's native structured-output path and validates the result against the same Pydantic schema — no client-side JSON regex anywhere. The CLI stays model-agnostic; pass `--model` to pin any model. Local and partially-compatible endpoints vary in structured-output fidelity, so `lint` stays mandatory there — which is the point: the disk check doesn't trust the model, regardless of vendor. The full capability matrix is in [`docs/provider_compatibility.md`](docs/provider_compatibility.md).

---

## When NOT to use it

Skip antemortem for trivial changes (typo, version bump), exploratory spikes with no spec yet, and hot-fixes where speed beats discipline. It validates your *plan against existing code* — it doesn't catch runtime bugs that live outside the files. It's a screening gate that runs **before** code review, tests, and design review, where changing direction is cheapest — not a replacement for them. Where antemortem sits relative to the rest of the toolkit is mapped in [`docs/toolkit_positioning.md`](docs/toolkit_positioning.md) ([한국어](docs/toolkit_positioning_kr.md)).

---

Built on real engineering: an offline test suite (`python -m pytest -q`, zero network in normal CI), an MCP server, four first-class providers, a deterministic decision gate, and a composite GitHub Action. The public claim surface is generated from source and self-checked — see [`docs/generated/claims.md`](docs/generated/claims.md) ([한국어](docs/generated/claims_kr.md)), validated by `python scripts/check_repo_consistency.py`.

```bash
pip install "antemortem[mcp]"      # MCP server + CLI
pip install antemortem             # CLI only
pip install "antemortem[ollama]"   # add local Ollama support
```

Deep dives in [`docs/`](docs/): CLI reference & exit codes · trust model · GitHub Action · MCP setup · schema (`src/antemortem/schema.py`) · decision rules (`src/antemortem/decision.py`). Methodology origin: [Antemortem](https://github.com/hibou04-ops/Antemortem).

License: Apache 2.0. © 2026 Kyunghoon Gwak.
