# Make Claude Code check your business rules with the FACET plugin

> Install the FACET plugin for Claude Code so every session sees the written rule behind a file, its FACET record, before editing it, is asked to review the record when it changes a rule's code, and leaves a drift report you can check afterwards.

Source: https://facet-framework.com/en/guides/stop-claude-code-guessing-business-rules/  
Last updated: 2026-11-26T23:33:14+01:00

You ask Claude Code to tidy up the discount module. The diff looks reasonable: among other things, the expiry check now compares against the end of the day in local time instead of UTC. Tests pass on the CI runner, which runs in UTC. What the diff does not tell you is that this exact comparison was a bug the team fixed in August, because codes expired a day early for customers west of UTC. Claude had no way to know.

FACET keeps a short, checkable description of each feature and its business rules, called a record, next to your code. By the end of this guide Claude Code reads the rule before it edits the file, and when it changes the code behind a rule anyway, it is asked to check the record before it finishes. Both come from the FACET plugin for Claude Code, which connects your records to every session through hooks, scripts Claude Code runs at fixed points of a session, and an MCP server, the standard way for AI assistants to look things up in other tools.

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, use a feature that already has a record and an anchor.

## Install the FACET plugin

The plugin comes from the FACET marketplace on GitHub. Add the marketplace, then install the plugin:

```sh
claude plugin marketplace add facet-framework/core
claude plugin install facet@facet-framework
```

Check that it is installed and enabled:

```sh
claude plugin list
```

![Terminal output: claude plugin marketplace add clones facet-framework/core and adds the marketplace facet-framework; claude plugin install installs facet@facet-framework; claude plugin list shows facet@facet-framework, scope user, enabled.](https://facet-framework.com/guides/stop-claude-code-guessing-business-rules/plugin-install-light.png)

*The plugin is installed for your user and enabled.*

The plugin is installed once per user and works in every project that has FACET records.

## Start the registry server once

In the project root, ask Claude Code to start its MCP servers:

```sh
claude mcp list
```

![Terminal output of claude mcp list: plugin:facet:registry, started by the plugin's mcp-launch.sh, Connected.](https://facet-framework.com/guides/stop-claude-code-guessing-business-rules/registry-connected-light.png)

*The plugin's registry server starts from the project and connects.*

The first start takes a few seconds longer: the plugin downloads FACET Core from the GitHub release and checks it against the release's checksums. The hooks in the next steps use that copy, so run this once before the first session.

## Mark where the session starts

Before you start the session, record the current state of the code as reviewed:

```sh
npx facet drift accept
```

It prints `Accepted baseline` with a commit hash. From now on, FACET compares against this point. Without it, FACET compares against the last commit, and a change Claude commits during the session would no longer show up at the end.

## See what Claude reads along with the file

Start a session in the project with `claude` and ask for the change, for example “Tidy up `src/checkout/discount.ts`”. At the start of the session the plugin gives Claude the list of records, so it knows where the rules are. When Claude opens `src/checkout/discount.ts`, the plugin adds this note right after the file:

```text
FACET claims for src/checkout/discount.ts, before editing:

checkout/discounts/redeem-code
  promises: A customer enters a discount code in the cart and gets its discount, or a reason why not.
  contract: expired-code-is-refused, last-day-ends-in-utc, minimum-order-value, one-code-per-order

Check these existing claims before changing observable behaviour. Use read_facet for the full intent or contract; update the record when its claims change.
```

`last-day-ends-in-utc` is the rule from the introduction. Claude can read its full text through the registry server's `read_facet` tool, without searching the repository.

## See what happens when Claude changes the rule anyway

A note can be overlooked. When Claude finishes its answer and has changed code that a record describes, but not the record, the plugin holds its answer once and asks for a review with this request:

```text
FACET: source implementing these features changed, but their records did not:

- checkout/discounts/redeem-code — changed: src/checkout/discount.ts

If any of these changes observable behaviour, the record belongs in the same
change (FACET spec 12.1). If they are behaviour-preserving, explain that review outcome.
Once that review is complete, 'facet drift accept' records the outcome.
```

Claude then has to say whether the change alters behaviour. A change to the expiry comparison does, so the honest answers are to undo it or to change the record in the same change, where a reviewer sees it.

A commit is checked too. When Claude runs `git commit` and the staged change breaks the link between records and code, for example by deleting the `@facet:` comment, the plugin refuses the command:

```text
FACET lint found new errors compared with HEAD in the staged commit:

  docs/facets/features/checkout/discounts/redeem-code.yaml: active record "checkout/discounts/redeem-code" has no @facet: anchor in source

Fix the records or the anchors, then commit again.
```

## Check the result after the session

You do not have to read the session to know whether a rule's code changed. In the project root, run:

```sh
npx facet drift
```

![Terminal output: npx facet drift accept records a baseline; after a commit that changes the expiry check, npx facet drift reports drift: checkout/discounts/redeem-code — changed: src/checkout/discount.ts; 1 drifted anchor, 0 reference changes, 0 stale references.](https://facet-framework.com/guides/stop-claude-code-guessing-business-rules/drift-after-session-light.png)

*A committed change to the expiry check shows up as drift on the discount record.*

The record Claude was asked to review appears in your terminal too, even after Claude committed the change. Decide what happens to it:

- The change was wrong: revert it with git, for example `git revert` for a commit.
- The change was intended: update the record's scenarios in the same branch, then mark the review as done:

```sh
npx facet drift accept --outcome record-updated
```

`npx facet drift` then reports `No drift found`.

> **What this does not do**
>
> The plugin tells Claude which rules apply and asks it to review its changes; it does not stop a change to the code
> behind a rule. The commit check only refuses commits that break the link between records and code, not commits that
> change behaviour. Your tests and your review still decide whether the change is right. The plugin reads the records
> your team writes; where there is no record, there is nothing to tell Claude.

## If the plugin says something else

- **`FACET Read context is unavailable without the facet binary`:** the plugin has not downloaded FACET Core yet. Run `claude mcp list` in the project once, as in step 2, then start a new session.
- **`claude mcp list` shows no `plugin:facet:registry`:** the plugin is not enabled. Check `claude plugin list`; if `facet@facet-framework` is missing, repeat step 1.
- **`To commit anyway, FACET_SKIP_COMMIT_GATE=1 must be set`:** the commit check refused the commit. Fix the record or the anchor it names. Only set the variable in your own shell before starting `claude` when you deliberately want to commit past the check; Claude cannot set it.
- **`Baseline: HEAD … no review recorded`:** no starting point was recorded, so only uncommitted changes are compared. Run `npx facet drift accept` before the next session, as in step 3.

For what changes when agents build features against written rules, read [The agent built it. Who checked it?](https://facet-framework.com/en/solutions/ai-built-products/).

### Sources

- [FACET Core: Claude Code plugin](https://github.com/facet-framework/core)
- [Claude Code: plugins](https://code.claude.com/docs/en/plugins)
- [Claude Code: hooks](https://code.claude.com/docs/en/hooks)
