# Catch outdated feature docs in the pull request with FACET

> List the documented features a branch changes with one command, see whether their FACET descriptions (records) changed too, and keep the pull request check that fails when description and code stop pointing at each other.

Source: https://facet-framework.com/en/guides/catch-it-in-the-pull-request/  
Last updated: 2026-11-26T23:33:14+01:00

A pull request changes one comparison in the discount code: `<` becomes `<=`. The diff is one character, the tests are green, two people approve it. Nobody opens the description of the discount rules two folders away, which still says that a cart at exactly the minimum order value gets the discount. From the next release on, support answers customers with a rule the shop no longer follows.

FACET keeps a short, checkable description of each feature, called a record, next to your code, linked to it by a comment in the code, and tells you when the two drift apart. By the end of this guide a reviewer gets the list of documented features a branch touches with one command, and sees at a glance whether their records changed too. `facet drift --baseline main` names every feature whose code changed on the branch. The FACET Lint check that `facet init` added to the repository keeps failing pull requests whose records and code no longer point at each other.

The commands below use a small example shop written in TypeScript, set up as in [One answer instead of three](https://facet-framework.com/en/guides/write-down-what-a-feature-does/), on a local branch. On your own repository, run them on the branch of the pull request you review.

## See what every pull request already checks

`facet init` wrote `.github/workflows/facet-lint.yml`. It runs on every pull request. Its trigger and its one step, with the comments left out:

```text
on:
  pull_request:
  workflow_dispatch:
# …
        run: |
          set -euo pipefail
          dispatcher=tools/facet-lint/facet
          [ -f "$dispatcher" ] || dispatcher=bin/facet
          sh "$dispatcher" --root "$GITHUB_WORKSPACE" lint
```

`tools/facet-lint/facet` is a small script, also written by `init`. It pins the FACET version that `init` came from (`FACET_VERSION`), downloads that release from GitHub, checks it against the release's checksums and runs it. Run the same command on your machine, from the project root:

```sh
sh tools/facet-lint/facet --root . lint
```

It ends with `1 record(s), 1 anchor(s) checked — 0 error(s), 1 warning(s)` and exit code 0. This is exactly what the pull request runs, so a result you see here is the result the check reports there.

## Make a change that only touches code

Create a branch and make the change from the introduction. In `src/checkout/discount.ts`, change the minimum-order comparison from `total < code.minSubtotal` to `total <= code.minSubtotal`:

```text
  if (code.minSubtotal !== undefined && total <= code.minSubtotal) throw new ShopError("E2003");
```

```sh
git switch -c equal-minimum-is-refused
git commit -am "Refuse a code when the subtotal equals the minimum"
```

Run the pull request check again:

```sh
sh tools/facet-lint/facet --root . lint
```

It still passes with 0 errors. The anchor is still there and the record is still valid; lint checks links, not behaviour.

## List the features this branch changes

Ask which documented features had their code changed on the branch, compared with `main`:

```sh
npx facet drift --baseline main
```

Then check whether any record changed on the branch:

```sh
git diff --stat main -- docs/facets
```

![Terminal output: npx facet drift --baseline main reports drift for checkout/discounts/redeem-code in src/checkout/discount.ts, 1 drifted anchor; git diff --stat main -- docs/facets prints nothing.](https://facet-framework.com/guides/catch-it-in-the-pull-request/drift-on-branch-light.png)

*The branch changes the discount-code feature, and no record changed with it.*

Together, the two answers are the review comment: this branch changes how discount codes are redeemed, and `docs/facets/features/checkout/discounts/redeem-code.yaml` did not change. The reviewer opens that record and reads the scenario `minimum-order-value`: "When the cart subtotal is below that value, then the shop refuses the code". The code now also refuses a subtotal equal to the minimum.

## Update the record in the same pull request

If the change is intended, the author updates the scenario in `redeem-code.yaml` on the same branch:

```text
    - id: minimum-order-value
      statement: |
        Given a code with a minimum order value
        When the cart subtotal is at or below that value
        Then the shop refuses the code with E2003
```

```sh
git commit -am "Record: a subtotal equal to the minimum is refused"
git diff --stat main -- docs/facets
```

```console
$ git diff --stat main -- docs/facets
 docs/facets/features/checkout/discounts/redeem-code.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
```

`npx facet drift --baseline main` still names the feature afterwards. Against a baseline you name, drift lists every feature whose code the branch changed, whether or not its record moved too; it does not decide whether the new wording is right. That stays the reviewer's call, now with the record and the code change side by side in the same pull request.

## See what makes the pull request check fail

The check fails when records and code stop pointing at each other. A common way is a cleanup that removes "unused" comments. Delete the two `// @facet:` lines above `redeemDiscountCode` in `src/checkout/discount.ts`, then run the pull request check:

```sh
sh tools/facet-lint/facet --root . lint
```

![Terminal output of sh tools/facet-lint/facet --root . lint: error, active record checkout/discounts/redeem-code has no @facet: anchor in source; warning, src/checkout/discount.ts lost a primary implementation reference; 1 record, 0 anchors checked, 1 error, 2 warnings.](https://facet-framework.com/guides/catch-it-in-the-pull-request/pr-check-red-light.png)

*Without its anchor the active record fails the check that runs on the pull request.*

The command exits with 1, so the workflow step fails and the pull request shows a failed FACET Lint check. Undo the experiment:

```sh
git checkout -- src/checkout/discount.ts
```

> **What this does not do**
>
> `facet drift` never fails a run; it is a list for the reviewer. The FACET Lint check fails on broken links between
> records and code, such as a missing anchor or a record whose id does not match its path, not on a behaviour change the
> record does not describe. Neither command reads the meaning of a diff.

## If the commands say something else

- **`drift could not be determined: baseline origin/main does not resolve to a commit`:** the revision does not exist in this clone. Use a branch you have locally, such as `main`, or fetch the target branch first.
- **`active record "…" has no @facet: anchor in source`:** the code that implements an active record lost its `@facet:` comment, or the file was deleted. Put the anchor on the code's new home, or set `lifecycle: planned` if the feature is gone for now.
- **`lost a primary implementation reference`:** a warning that comes with the error above. It names the file that used to carry the anchor.
- **`No drift found`, but you expected a feature:** the changed file carries no `@facet:` anchor. Drift only knows features that have a record and an anchor.

For more on descriptions that fall behind the code, read [The help article says 14 days. The code says 30.](https://facet-framework.com/en/solutions/living-documentation/).

### Sources

- [FACET Core: quick start](https://github.com/facet-framework/core#quick-start)
- [GitHub Actions: events that trigger workflows, `pull_request`](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request)
