Facet
DeutschInstall
Tests & regressions

Find which features break most often, from your git history with FACET

Turn the bug-fix commits you already have into a ranking of features by how often their code needed fixing, and see which fixes belong to no feature yet.

  • 7 min read
  • 5 steps
  • GitConventional Commits
  • Your coding agent

In every retro someone says "checkout is fragile", and everyone nods. Nobody can say whether that is true, or whether it only feels true because the last incident was in checkout. The planning meeting then decides on a rewrite, or on nothing, based on that feeling.

FACET keeps a short description of each feature, called 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, next to your code, and comments in the code, called 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, tie each file to its feature. By the end of this guide you have a ranking of your features by how often their code needed a fix, read from the git history you already have. facet defects backfill finds the bug-fix commits, maps the files each one changed to the feature records anchored in them, and writes the result into those records. facet defects then lists the features, most fixed first.

The commands below use a small example shop written in TypeScript, set up as in One answer instead of three, with 28 commits from 2026. In your own project, start with the last three to six months.

Step 1See which fixes the history already holds

Start with a dry run. It reads the history and writes nothing:

sh
  • npx facet defects backfill --dry-run --since 2026-01-01
Terminal output of the dry run: three fix commits are attributed to checkout/discounts/redeem-code, all in src/checkout/discount.ts; 5 candidate commits, would record 3 fixes; 2 fix commits touched no anchored file: one for refunds, one for password reset. Nothing was written.Terminal output of the dry run: three fix commits are attributed to checkout/discounts/redeem-code, all in src/checkout/discount.ts; 5 candidate commits, would record 3 fixes; 2 fix commits touched no anchored file: one for refunds, one for password reset. Nothing was written.
Five fix commits this year: three land on discount codes, two on no feature at all.

FACET treats a commit as a fix when its subject starts like a Conventional Commit: fix:, fix(scope):, hotfix: or bugfix:. Each fix is attributed by the files it changed: a file that carries an @facet: anchor belongs to that feature.

The lower part matters as much as the upper one. Two fixes, one to refunds and one to password reset, changed files that no record claims. They are not lost, they are listed: that is the part of the product this ranking cannot see yet.

Step 2Give the unattributed fixes a feature to land on

The refund fix landed in src/orders/refund.ts, which no record claims. Write a record for refunds. 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-refundlifecycle: activeintent:  summary: A customer asks for money back on an order and gets it, in full or in part, or a reason why not.contract:  scenarios:    - id: refund-within-window      statement: |        Given an order delivered 29 days ago        When the customer requests a refund        Then the refund is accepted and goes back to the original payment method    - id: refund-after-window      statement: |        Given an order delivered 31 days ago        When the customer requests a refund        Then the shop refuses it with E3001    - id: partial-refunds-up-to-total      statement: |        Given an order that was already partly refunded        When a further refund would exceed the amount paid        Then the shop refuses it with E3002    - id: gift-card-as-store-credit      statement: |        Given an order paid with a gift card        When the customer requests a refund        Then the money comes back as store creditlineage:  owner:    team: orders  created_at: "2026-11-22"

Anchor it with two comment lines directly above export function requestRefund in src/orders/refund.ts:

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

Check that record and anchor point at each other:

sh
  • npx facet lint

The summary line reads 2 record(s), 2 anchor(s) checked — 0 error(s), 2 warning(s). The warnings say that no test claims the refund ScenarioA scenario is one behaviour a feature promises, written in a record as Given/When/Then steps. Each scenario has an id that tests and other records can refer to.Read more here yet and that two test files, invoice.test.ts and refund.test.ts, belong to no record; neither affects the ranking. The anchor counts for the whole history: attribution uses today's anchors, so a fix from September now belongs to refunds.

Step 3Write the fixes into the records

Run the same command without --dry-run:

sh
  • npx facet defects backfill --since 2026-01-01
Terminal output of npx facet defects backfill: three fixes recorded for checkout/discounts/redeem-code, one for orders/refunds/request-refund in src/orders/refund.ts; 5 candidate commits, recorded 4 fixes; one fix commit for a password reset link remains unattributed.Terminal output of npx facet defects backfill: three fixes recorded for checkout/discounts/redeem-code, one for orders/refunds/request-refund in src/orders/refund.ts; 5 candidate commits, recorded 4 fixes; one fix commit for a password reset link remains unattributed.
Four of five fixes now belong to a feature; the password-reset fix is still unattributed.

FACET adds a defects block to each record and changes nothing else in the file. In redeem-code.yaml it starts like this:

yaml
defects:  fixes:    - commit: "5f7c93a5344164b2124f65848f1cccecf8a9ad2a"      date: "2026-04-02"      files:        - src/checkout/discount.ts      subject: "fix(checkout): accept discount codes regardless of letter case"      recorded_by: git-history

Running the command again is safe. A commit a record already holds is skipped, and the second run reports recorded 0 fix(es), skipped 4 already known.

Step 4Read the ranking

sh
  • npx facet defects
Terminal output of npx facet defects: 3 fixes for checkout/discounts/redeem-code, last fix 2026-09-24, all in src/checkout/discount.ts; 1 fix for orders/refunds/request-refund, last fix 2026-09-01; 4 recorded fixes across 2 features.Terminal output of npx facet defects: 3 fixes for checkout/discounts/redeem-code, last fix 2026-09-24, all in src/checkout/discount.ts; 1 fix for orders/refunds/request-refund, last fix 2026-09-01; 4 recorded fixes across 2 features.
Discount codes needed three fixes this year, refunds one.

In the example shop, the fragile part is not checkout as a whole. It is discount-code redemption: three fixes in one file, the last one in September. That is a concrete question for the next planning meeting: an extra reviewer for src/checkout/discount.ts, more tests, or a rewrite.

To rank files instead of features:

sh
  • npx facet defects --by-file
console
  • npx facet defects --by-file
  • 3      src/checkout/discount.ts
  • 1      src/orders/refund.ts
  • 2 file(s) with a recorded fix

Commit the updated records with the new anchor, so the whole team reads the same numbers:

sh
  • git add docs/facets src/orders/refund.ts
  • git commit -m "Record which features needed fixes this year"

Step 5If the numbers look wrong

  • No record carries a defect ledger. Run 'facet defects backfill' to fill one from git history.: nothing has been written yet. Run the backfill without --dry-run.
  • candidate(s) touched no anchored file and were not attributed: the fix changed files without an @facet: anchor. Anchor those files to a record, as in step 2, and run the backfill again; known commits are skipped.
  • Your team does not write fix: in commit subjects: state your own convention as a regular expression with --match, for example npx facet defects backfill --dry-run --since 2026-01-01 --match '^(fix|bug)[:(]'. Check the dry run before you write.
  • The first run takes long: the walk is linear in commits. Keep --since or --limit bounded and widen it step by step.

For more on finding the parts of a product everyone is afraid to touch, read Nobody wants to touch the pricing logic. And everyone has to, eventually.

Sources