# Try FACET on your codebase without changing the shared repo

> Run FACET on your own clone with real feature descriptions and the code comments that link them, while a Git filter keeps those comments out of your commits and your excluded files stay off the remote.

Source: https://facet-framework.com/en/guides/try-facet-without-touching-the-repo/  
Last updated: 2026-11-26T23:28:23+01:00

You want to know whether writing feature behaviour down next to the code would actually help on your ten-year-old codebase. To find out, you need records and a few marker comments in real source files. But the architecture meeting is in three weeks, and until then nobody will approve new comments in shared code, let alone new folders in the repository.

FACET is a command-line tool that keeps a short, checkable description of each feature, called a record, next to your code, and links the code to it with marker comments called anchors. By the end of this guide FACET runs on your own clone with real records and real anchors, while every commit and push you make stays exactly as it would have been. The anchors live only in your working copy: FACET's private anchors are a Git filter that takes them out on the way into a commit and puts them back on checkout.

The commands below use a small example shop written in TypeScript, in a clone that has never seen FACET. In your own project, run them in the root of your clone and pick one feature you know well.

## Install FACET outside the repository

A dev dependency would change `package.json`, so install FACET into a folder in your home directory instead:

```sh
npm install --prefix ~/.facet facet-framework
```

Put its `facet` command on your PATH for this terminal session, and check that it runs:

```sh
export PATH="$HOME/.facet/node_modules/.bin:$PATH"
facet version
```

The first line starts with `facet core`. Add the `export` line to your shell profile if you want `facet` in every new terminal. The Git filter from step 3 calls the binary inside `~/.facet` directly, so keep that folder where it is.

## Set up FACET without leaving a trace in Git

Change into the root of your clone. Create FACET's files there:

```sh
facet init
```

`init` writes the record folder `docs/facets/`, a lint suite in `tools/facet-lint/`, an empty `.facetignore` and a CI workflow. Keep all four out of Git with your clone's own exclude file, `.git/info/exclude`. It works like `.gitignore`, but it is never committed:

```sh
printf 'docs/facets/\n.facetignore\n.github/workflows/facet-lint.yml\ntools/facet-lint/\n' >> .git/info/exclude
```

Tell the scan to skip the lint suite, so its own self-test is not reported as a test file without a record:

```sh
printf 'tools/facet-lint/\n' >> .facetignore
```

Check what Git sees:

```sh
git status --short
```

It prints nothing. The files exist on your disk and nowhere else.

## Turn on private anchors for this clone

```sh
facet filter install
```

![Terminal output: git status --short prints nothing; facet filter install says private anchors are enabled and lists the filter command in ~/.facet, the attributes file and the sidecar folder, both inside .git.](https://facet-framework.com/guides/try-facet-without-touching-the-repo/filter-install-light.png)

*The filter settings and the sidecar live inside .git of your clone.*

The command writes two things, both inside `.git`: the filter in `.git/config` and a line in `.git/info/attributes`. The sidecar folder `.git/facet/anchors/` named in the output remembers where each private anchor stands; it appears only with your first private anchor. Nothing in the repository changes.

## Write a record and anchor it privately

Write one record for a feature you know. In the example shop it is redeeming a discount code. Create the folder:

```sh
mkdir -p docs/facets/features/checkout/discounts
```

Save this as `docs/facets/features/checkout/discounts/redeem-code.yaml`:

```yaml
schema_version: "0.1"
id: checkout/discounts/redeem-code
lifecycle: active
intent:
  summary: A customer enters a discount code in the cart and gets its discount, or a reason why not.
contract:
  scenarios:
    - id: expired-code-is-refused
      statement: |
        Given the code SPRING5, whose last day is 2026-05-31
        When a customer redeems it after 23:59:59 UTC on that day
        Then the shop refuses it with E2002 and the cart keeps its price
    - id: last-day-ends-in-utc
      statement: |
        Given a code whose last day is today
        When a customer redeems it at 23:30 UTC, in any time zone
        Then the discount is applied
    - id: minimum-order-value
      statement: |
        Given a code with a minimum order value
        When the cart subtotal is below that value
        Then the shop refuses the code with E2003
    - id: one-code-per-order
      statement: |
        Given a cart that already has a code
        When the customer enters a second code
        Then the shop refuses it with E2004
verification:
  unit_tests:
    - id: tests/discount.test.ts
      proves: [expired-code-is-refused, last-day-ends-in-utc, minimum-order-value, one-code-per-order]
lineage:
  owner:
    team: checkout
  created_at: "2026-11-22"
```

Add the anchor, two comment lines on their own, directly above the function in `src/checkout/discount.ts`:

```ts
// @facet: checkout/discounts/redeem-code
// @facet-role: primary
/** Redeems a code on a cart. Returns the new cart; throws a ShopError and leaves the cart unchanged otherwise. */
export function redeemDiscountCode(cart: Cart, input: string, now = new Date()): Cart {
```

Git may now list the file as modified while `git diff` shows nothing, because Git compares sizes before it asks the filter. Clear that, then run the check:

```sh
facet filter refresh
facet lint
```

`git status --short` prints nothing again, and `facet lint` ends with `1 record(s), 1 anchor(s) checked — 0 error(s)`. FACET sees the anchor; Git does not.

## Work and commit as usual

Make a normal change in the same file and commit it the way you always do. In the example, add a discount code:

```sh
git add src/checkout/discount.ts
git commit -m "Add the WINTER20 discount code"
```

Look at what the commit contains, and at what your editor still shows:

```sh
git show --format=%s HEAD
grep -n '@facet' src/checkout/discount.ts
```

![Terminal output: git show of the commit adds one line, the WINTER20 code, and no anchor; grep finds the two anchor lines at lines 24 and 25 of the working copy; git status --short prints nothing.](https://facet-framework.com/guides/try-facet-without-touching-the-repo/private-commit-light.png)

*The commit holds your change; the anchor stays in your working copy.*

The commit adds one line and nothing else. Your reviewers, CI and `git blame` see the file as it was. Line numbers in CI output and stack traces refer to the committed file, which has two lines fewer above the function than your editor shows.

## Put an anchor back when a pull moves its line

A private anchor sits above a particular line and follows that line when other changes move it. When a colleague rewrites the line itself, the anchor has nowhere to go. `git pull` says so:

```sh
git pull
facet filter status
facet lint
```

![Terminal output: git pull reports that 1 private anchor has no place in this version and was kept aside; facet filter status marks the anchor with an exclamation mark, no place in the current file, and quotes the doc comment it used to stand above; facet lint reports that the active record has no anchor in source: 1 error.](https://facet-framework.com/guides/try-facet-without-touching-the-repo/anchor-lost-place-light.png)

*The colleague reworded the doc comment: the anchor is kept aside, not guessed.*

FACET does not move the anchor to a nearby line on its own. `facet filter status` quotes the line it used to stand above, so you can find the spot. Add the two comment lines again above the reworded comment, then:

```sh
facet filter refresh
facet lint
```

`facet filter status` shows the anchor above its new line, and `facet lint` is back to `0 error(s)`.

## Share it, or remove every trace

Before you turn the filter off, note which files carry private anchors. `facet filter status` lists them. Then:

```sh
facet filter uninstall
```

Your private anchors stay in the working copy and become ordinary lines. Git may still report the files as unchanged, because it remembers them as clean from the time the filter ran. Make Git read them again:

```sh
git add --renormalize .
git status --short
```

Now the files with anchors appear as staged changes. When the team adopts FACET, delete the four lines you added to `.git/info/exclude`, add the records and FACET's files, and commit everything in one pull request.

If the answer is no, remove the anchor lines from the files `facet filter status` listed, delete the four lines from `.git/info/exclude`, and delete the files `init` created. `uninstall` leaves the sidecar in `.git/facet/` in case you turn the filter on again; delete that folder as well.

> **What this does not do**
>
> Private anchors exist only in your clone. CI and your colleagues' clones see no anchors, so `facet lint` there reports
> every privately anchored record as unanchored. Your records are excluded files: they are not backed up by a push, and
> a fresh clone does not have them. Git needs the `facet` binary for every `git status`, `add` and `checkout` in this
> clone while the filter is on.

## If Git or the check says something else

- **`fatal: src/checkout/discount.ts: clean filter 'facet' failed`, together with `facet: not found`:** the filter calls the binary at the exact path it was installed from, and that path is gone. Install FACET to `~/.facet` again, or run `facet filter install` with the new binary. The filter refuses to run without it on purpose: skipping it once would commit your private anchors.
- **`git status` lists a file as modified, `git diff` shows nothing:** you added or edited a private anchor. Run `facet filter refresh`.
- **`1 private anchor(s) have no place in this version and were kept aside`:** a pull or checkout changed the line the anchor stood above. Follow step 6.
- **`active record "…" has no @facet: anchor in source`:** the anchor is missing from the working copy. `facet filter status` lists the private anchors the filter keeps and where each one stands.
- **`warning: : no schema directory at docs/facets/schema — schema validation skipped`:** `facet init` has not run in this clone. Run it as in step 2.

For more on bringing an old codebase under control one feature at a time, read [Nobody wants to touch the pricing logic. And everyone has to, eventually.](https://facet-framework.com/en/solutions/legacy-systems/)

### Sources

- [Where each language puts its `@facet:` anchor](https://github.com/facet-framework/core/blob/main/docs/ANCHOR-GUIDE.md)
- [How to write a record](https://github.com/facet-framework/core/blob/main/docs/AUTHORING.md)
- [Git: excluding files locally with `.git/info/exclude`](https://git-scm.com/docs/gitignore)
- [Git: clean and smudge filters](https://git-scm.com/docs/gitattributes#_filter)
