You tidy up a folder name, commit, push and switch to the next task. Ten minutes later CI is red: a FACET recordA FACET record is a short, checkable description of one feature, kept as a YAML file next to the code. It states why the feature exists, the behaviour it promises as scenarios, and the tests that check it.In the glossary no longer matches its path, and the code still points at the old id. Now you context-switch back, fix it, push again, and wait for the pipeline a second time.
FACET keeps a short description of each feature, called a record, in a file next to your code, and a comment in the code, called an AnchorAn anchor is a comment in the source code, starting with @facet:, that names the record the code belongs to. FACET reads these comments to know where each feature is implemented.In the glossary, names the record it belongs to. Rename a folder, and the two can stop matching. By the end of this guide that commit never leaves your laptop. facet setup precommit installs a git pre-commit hook that runs facet lint --staged: it checks the change you are about to commit and refuses it when it introduces a broken record or anchor. Errors that were already there before your change do not stop you.
The commands below use a small example shop written in TypeScript, set up as in One answer instead of three. They work the same in any Git repository with FACET records.
Step 1Put facet on your PATH
The hook calls facet by name. A plain git commit does not see the project's node_modules/.bin, so the development dependency from “One answer instead of three” is not enough. Install the same version globally:
npm install --global facet-framework
Check that your shell finds it outside npx:
facet version
The first line starts with facet core. Keep the global version the same as the one in package.json, so the hook and CI judge with the same rules.
Step 2Install the pre-commit hook
Preview what will happen. Without options nothing is written:
npx facet setup precommit
npx facet setup precommitDry run: would install ~/demo-shop/.git/hooks/pre-commit, which runs 'facet lint --staged' and fails the commit when 'facet' is not on PATH.Run with --write to do it.
Then install it:
npx facet setup precommit --write
npx facet setup precommit --writeWrote ~/demo-shop/.git/hooks/pre-commit.
The hook is a short shell script in .git/hooks/pre-commit. Git does not version that folder, so each person on the team runs this step once in their clone.
Step 3Try the commit that would break CI
Rename the record folder, as a quick tidy-up might:
git mv docs/facets/features/checkout/discounts docs/facets/features/checkout/discount-codesgit commit -m "Rename the discounts folder"


No commit was created. The record's id still says checkout/discounts/redeem-code, its new path implies checkout/discount-codes/redeem-code, and the anchor in the code points at an id that no longer has a record at the matching path. These are the same errors the pull request check would have reported ten minutes later.
To see the same result without committing, run the check the hook runs:
npx facet lint --staged
Step 4Fix it and commit
A rename of a record is three changes that belong together: the folder, the id in the record and every @facet: anchor that names it. Here, the quick fix is to undo the rename:
git mv docs/facets/features/checkout/discount-codes docs/facets/features/checkout/discounts
Then commit something that does not break anything, for example a line added to README.md:
git add README.mdgit commit -m "Mention free shipping in the README"


The hook only judges what the commit introduces. If HEAD already contains an error, for example because someone committed with --no-verify, an unrelated commit still goes through, and npx facet lint on the whole repository keeps reporting the old error.
To remove the hook again:
npx facet setup precommit --remove
It deletes the file only if FACET wrote it.
Step 5If the hook says something else
facet pre-commit: 'facet' is not on PATH, so the staged records and anchors were NOT checked.: the commit was refused because the hook could not run the check. Install facet globally as in step 1, or check that the global npm folder is on your PATH. A GUI git client may use a different PATH than your terminal.npm error code EACCESduring the global install: your npm installs global packages into a system folder you cannot write to. Follow npm's guide to change the default directory, or use a Node version manager; do not usesudo.husky is present, so no git hook file is written. Add this line to .husky/pre-commit:: your project manages hooks with husky. Add the printed linefacet lint --stagedto.husky/pre-commityourself.… already exists and was not written by FACET, so it is left alone.: you already have a pre-commit hook. FACET prints the lines to add to it and changes nothing.
For more on catching broken changes before they reach others, read “That line can go.” Are you sure?