# Know when a help article no longer matches the code, with FACET

> Correct one help article against the code, tie it to a FACET record, and let facet docs check name the article whenever the code or the rule behind it changes.

Source: https://facet-framework.com/en/guides/help-article-says-14-days-code-says-30/  
Last updated: 2026-11-26T01:08:50+01:00

A customer writes to support: “Your help centre says I can return items within 14 days. I am on day 20 and the shop just accepted my refund. Which one is it?” Support checks with a developer. The code has allowed 30 days since spring. Nobody updated the article, and nobody would have noticed if the customer had not asked.

FACET keeps a short, checkable description of each feature, called a record, next to your code, and can tie other documents, such as help articles, to it. By the end of this guide the help article states what the code does, and it is tied to that code. When someone changes the refund rule, `facet docs check` names the article that is now out of date, on your machine and in every pull request.

The commands below use a small example shop written in TypeScript; FACET has to be set up as in [One answer instead of three](https://facet-framework.com/en/guides/write-down-what-a-feature-does/). In your own project, pick one help article that customers quote and the code it describes.

## Find out what the code really allows

Before touching the article, read the code that decides. In the example shop it is `src/orders/refund.ts`:

```ts
export const refundWindowDays = 30;

export function requestRefund(order: Order, now = new Date()): { orderId: string; amountCents: number } {
  const deadline = order.placedAt.getTime() + refundWindowDays * 24 * 60 * 60 * 1000;
  if (now.getTime() > deadline) throw new ShopError("E3001");
  return { orderId: order.id, amountCents: order.totalCents };
}
```

Now compare it with the article. The example shop has no help centre, so save the article customers quote as `help/returns.md`:

```text
# Returns and refunds

You can return any item within **14 days** of delivery.

1. Open **My orders** and choose the order.
2. Select **Request a refund**.

Refunds usually arrive within five working days.
```

The article is wrong twice. The window is 30 days, not 14, and it starts when the order is placed, not on delivery: the code counts from `placedAt`, and the shop stores no delivery date at all.

## Write the rule down next to the code

The article needs something to be checked against. Write the refund rules into a FACET record. Create the folder:

```sh
mkdir -p docs/facets/features/orders/refunds
```

Save this as `docs/facets/features/orders/refunds/request-refund.yaml`:

```yaml
schema_version: "0.1"
id: orders/refunds/request-refund
lifecycle: active
intent:
  summary: A customer asks for the money back on an order and gets the order total refunded, or a reason why not.
contract:
  scenarios:
    - id: request-inside-window-is-accepted
      statement: |
        Given an order placed 30 days ago
        When the customer requests a refund
        Then the shop refunds the order total
    - id: late-request-is-refused
      statement: |
        Given an order placed 31 days ago
        When the customer requests a refund
        Then the shop refuses it with E3001
lineage:
  owner:
    team: orders
  created_at: "2026-11-22"
```

Then connect the record to the code. Add two comment lines directly above `requestRefund` in `src/orders/refund.ts`:

```ts
// @facet: orders/refunds/request-refund
// @facet-role: primary
export function requestRefund(order: Order, now = new Date()): { orderId: string; amountCents: number } {
```

Check that record and code point at each other:

```sh
npx facet lint
```

The summary line reads `2 record(s), 2 anchor(s) checked — 0 error(s)`. The two warnings say that no test is named for the new scenarios yet and that two test files, `invoice.test.ts` and `refund.test.ts`, have no record. Warnings never fail the check.

## Correct the help article

Rewrite `help/returns.md` so it says what the record says:

```text
# Returns and refunds

You can return an order within **30 days** of placing it.

1. Open **My orders** and choose the order.
2. Select **Request a refund**.
3. You get the full order total back.

Refunds usually arrive within five working days.
```

Write it by hand or with the tool you already use for help content. What matters for the next step is that the article now matches the record and the code.

## Tie the article to the record and the code

Tell FACET which record the article was written from:

```sh
npx facet docs record --artifact help/returns.md --feature orders/refunds/request-refund --pipeline hand-written
```

FACET stores a content fingerprint of the record and of every file that carries its anchor, here `src/orders/refund.ts`, in `docs/facets/generated.lock.yaml`. `--pipeline` only names how the article was made. Then check the article:

```sh
npx facet docs check
```

![Terminal output: npx facet docs record says it recorded help/returns.md with 2 inputs in docs/facets/generated.lock.yaml; npx facet docs check reports 1 artifact checked, 0 need regeneration.](https://facet-framework.com/guides/help-article-says-14-days-code-says-30/docs-record-light.png)

*The article is tied to its record and its code, and is current.*

Commit the record, the anchor, the corrected article and the lock file together:

```sh
git add docs/facets help/returns.md src/orders/refund.ts
git commit -m "Correct the refund window in the help article and tie it to the refund rule"
```

## Change the rule and watch the article get flagged

Months later, a developer extends the refund window for the holidays. Open `src/orders/refund.ts` and change the constant:

```ts
export const refundWindowDays = 45;
```

Nobody thinks of the help centre. Run the check:

```sh
npx facet docs check
```

![Terminal output of npx facet docs check: stale: help/returns.md (orders/refunds/request-refund), input src/orders/refund.ts changed since generation; 1 artifact checked, 1 needs regeneration.](https://facet-framework.com/guides/help-article-says-14-days-code-says-30/docs-stale-light.png)

*A change to the refund code marks the help article as stale.*

The article is flagged by name, together with the file that changed. A change to the record would flag it the same way.

## Make the pull request fail until the article follows

Plain `docs check` only reports; it exits 0. Add `--strict` to make it fail while an article is stale:

```sh
npx facet docs check --strict
```

It prints the same report and exits with status 1. To run it on every pull request, add one line to the workflow `init` wrote, `.github/workflows/facet-lint.yml`, after the line that runs `lint`:

```text
          sh "$dispatcher" --root "$GITHUB_WORKSPACE" lint
          sh "$dispatcher" --root "$GITHUB_WORKSPACE" docs check --strict
```

Now the developer who changes the refund window also sees the help article in the failed check. Update the record's scenarios and the article to 45 days, then record the article again:

```sh
npx facet docs record --artifact help/returns.md --feature orders/refunds/request-refund --pipeline hand-written
npx facet docs check --strict
```

The check reports `1 artifact(s) checked — 0 need regeneration` and exits 0.

> **What this does not do**
>
> `facet docs check` compares fingerprints. It knows that the code or the record changed since the article was last
> recorded, not whether the article is now wrong: a refactor that keeps the behaviour flags the article too. It does not
> read the article, does not find a mismatch that already existed before you recorded it, and does not rewrite anything.

## If the check says something else

- **`no such file or directory` after `record for orders/refunds/…`:** the `--feature` id has no record file. Copy the `id:` from the record.
- **`no such file or directory` after `generated artifact help/…`:** the `--artifact` path is wrong. Give it relative to the repository root.
- **`--feature and --artifact are both required`:** add the missing flag.
- **`orphaned: help/returns.md`, with `feature record … no longer exists`:** the record was deleted or renamed. Point the article at the new id with `docs record`, or remove its entry from `docs/facets/generated.lock.yaml` if the article is gone.
- **`stale` after a change that does not affect customers:** read the diff. If the article is still right, run `docs record` again to accept the new state.

For why teams keep help content tied to the code it describes, read [The help article says 14 days. The code says 30.](https://facet-framework.com/en/solutions/living-documentation/).

### Sources

- [FACET specification, generation freshness (§8.6)](https://github.com/facet-framework/core/blob/main/docs/framework/FACET.md)
- [How to write a record](https://github.com/facet-framework/core/blob/main/docs/AUTHORING.md)
