One team describes every button as its own feature and has hundreds of tiny entries nobody reads. Another team has one entry called "cart and checkout" with thirteen cases, and every change touches it. Both say they describe the product. Neither can say whether their way is the right one, and each single entry looks fine on its own.
FACET keeps a short, checkable description of each feature, called a record, next to your code and tells you when code and description DriftDrift is when code changes and the record describing it does not follow, so the two no longer match. facet drift lists the features whose anchored code changed since a chosen baseline.In the glossary apart. By the end of this guide you can measure how your product is cut into features with npx facet calibrate, split a record that has grown into a whole area, and check with npx facet split --check that the split lost nothing the old record said.
The commands below use the example shop from “One answer instead of three”. In your own project, run step 2 first and pick the record the measurement points at.
Step 1Start from one record that covers too much
In the example shop, a colleague described cart, shipping and ordering in one record. Recreate it. Create the folder:
mkdir -p docs/facets/features/checkout/cart
Save this as docs/facets/features/checkout/cart/cart-and-checkout.yaml:
schema_version: "0.1"id: checkout/cart/cart-and-checkoutlifecycle: activeintent: summary: A customer fills a cart, sees the total with shipping and places the order.contract: scenarios: - id: subtotal-in-cents statement: | Given two mugs at 12.90 EUR and a tea sampler at 24.50 EUR When the customer looks at the cart Then the subtotal is 50.30 EUR - id: same-product-one-line statement: | Given a cart with one mug When the customer adds another mug Then the cart has one line with quantity 2 - id: zero-quantity-refused statement: | Given any cart When the customer adds a product with quantity 0 Then the cart refuses it - id: unknown-product-refused statement: | Given any cart When a product id the catalogue does not know is added Then the cart refuses it - id: free-shipping-from-50 statement: | Given a cart worth 59.00 EUR after discounts When the customer places the order Then shipping is free - id: shipping-below-50 statement: | Given a cart worth 12.90 EUR When the customer places the order Then shipping costs 4.90 EUR - id: discount-counts-before-free-shipping statement: | Given a cart worth 52.00 EUR and a discount of 5.00 EUR When the customer places the order Then shipping costs 4.90 EUR, because 47.00 EUR is below the threshold - id: legacy-checkout-always-charges-shipping statement: | Given the flag new_checkout_v2 is off When the customer places an order worth 59.00 EUR Then shipping costs 4.90 EUR - id: empty-cart-refused statement: | Given an empty cart When the customer places the order Then the order is refused - id: order-total statement: | Given a cart with a subtotal, a discount and shipping When the customer places the order Then the total is subtotal minus discount plus shipping - id: order-keeps-payment-method statement: | Given a customer paying with a gift card When the order is placed Then the order records the gift card as payment method - id: order-has-no-refunds-yet statement: | Given a new order When it is placed Then it has no refunds - id: order-time-is-recorded statement: | Given a customer placing an order When the order is placed Then the order records the time it was placedverification: unit_tests: - id: tests/cart.test.ts proves: [subtotal-in-cents, same-product-one-line, zero-quantity-refused] - id: tests/checkout.test.ts proves: [free-shipping-from-50, shipping-below-50, legacy-checkout-always-charges-shipping, empty-cart-refused]lineage: owner: team: checkout created_at: "2026-11-22" depends_on: - checkout/discounts/redeem-code
depends_on says that this feature relies on discount codes: the free-shipping threshold counts after the discount.
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 it in src/checkout/checkout.ts, directly above placeOrder:
// @facet: checkout/cart/cart-and-checkout// @facet-role: primaryexport function placeOrder(cart: Cart, paidWith: PaymentMethod, now = new Date()): Order {
Commit it, as the colleague did:
git add docs srcgit commit -m "Describe cart and checkout in one record"
Step 2Measure how the product is cut
npx facet calibrate


calibrate looks at the whole list instead of one record. Each line compares a median with a band that usually fits, and ! marks a line with records outside it:
- scenarios per record, 1 above: one record has more than nine scenarios. Thirteen cases usually means the record describes a whole area, not one feature. Below two, a record is usually a single case of a bigger feature.
- records per capability, 2 below: each capability holds one record, so the middle level of the ids (
cart,discounts) does not group anything yet.
npx facet lint says the same about the single record: declares 13 contract scenarios, as a warning.
Step 3Cut where the scenarios stop referring to each other
Read the thirteen scenarios and look for groups that never mention each other. Here there are three:
- What is in the cart:
subtotal-in-cents,same-product-one-line,zero-quantity-refused,unknown-product-refused - What shipping costs:
free-shipping-from-50,shipping-below-50,discount-counts-before-free-shipping,legacy-checkout-always-charges-shipping - Placing the order:
empty-cart-refused,order-total,order-keeps-payment-method,order-has-no-refunds-yet,order-time-is-recorded
Each group becomes a record in the same folder. Move the scenarios unchanged, keep their ids, and move each proves entry with its scenarios. Save the first group as docs/facets/features/checkout/cart/add-items.yaml:
schema_version: "0.1"id: checkout/cart/add-itemslifecycle: activeintent: summary: A customer puts products into the cart and sees the subtotal.contract: scenarios: - id: subtotal-in-cents statement: | Given two mugs at 12.90 EUR and a tea sampler at 24.50 EUR When the customer looks at the cart Then the subtotal is 50.30 EUR - id: same-product-one-line statement: | Given a cart with one mug When the customer adds another mug Then the cart has one line with quantity 2 - id: zero-quantity-refused statement: | Given any cart When the customer adds a product with quantity 0 Then the cart refuses it - id: unknown-product-refused statement: | Given any cart When a product id the catalogue does not know is added Then the cart refuses itverification: unit_tests: - id: tests/cart.test.ts proves: [subtotal-in-cents, same-product-one-line, zero-quantity-refused]lineage: owner: team: checkout created_at: "2026-11-22"
Save the second as shipping-fee.yaml with id: checkout/cart/shipping-fee, the summary "The order pays 4.90 EUR shipping unless it is worth 50 EUR or more after discounts.", the four shipping scenarios and tests/checkout.test.ts proving free-shipping-from-50, shipping-below-50 and legacy-checkout-always-charges-shipping.
Save the third as place-order.yaml with id: checkout/cart/place-order, the summary "A customer turns the cart into an order with its total, payment method and time.", the five ordering scenarios and tests/checkout.test.ts proving empty-cart-refused.
Then remove the old record:
git rm docs/facets/features/checkout/cart/cart-and-checkout.yaml
Step 4Check what the split dropped
The old record is gone from your working tree, but still in the last commit. Compare it with the three new ones:
npx facet split --check checkout/cart/cart-and-checkout checkout/cart/add-items checkout/cart/shipping-fee checkout/cart/place-order


The scenarios all arrived, because you moved them. What fell through is the relationship nobody thinks about when copying cases: lineage: depends_on — checkout/discounts/redeem-code. Shipping is the part that relies on the discount, so add it to shipping-fee.yaml. Its lineage block then reads:
lineage: owner: team: checkout created_at: "2026-11-22" depends_on: - checkout/discounts/redeem-code
Run the check again:
npx facet split --check checkout/cart/cart-and-checkout checkout/cart/add-items checkout/cart/shipping-fee checkout/cart/place-order
npx facet split --check checkout/cart/cart-and-checkout checkout/cart/add-items checkout/cart/shipping-fee checkout/cart/place-ordercheckout/cart/cart-and-checkout (read from HEAD:docs/facets/features/checkout/cart/cart-and-checkout.yaml)split into checkout/cart/add-items, checkout/cart/place-order, checkout/cart/shipping-feeNothing the parent carried is missing from all of the children.
Step 5Move the anchors and measure again
npx facet lint now reports four errors: the comment in src/checkout/checkout.ts still names checkout/cart/cart-and-checkout, and the three new records have no anchor. Point each record at its code:
- In
src/checkout/checkout.ts, change// @facet: checkout/cart/cart-and-checkoutaboveplaceOrderto// @facet: checkout/cart/place-order. - In the same file, add
// @facet: checkout/cart/shipping-feeand// @facet-role: primaryabovefunction shippingFor. - In
src/checkout/cart.ts, add// @facet: checkout/cart/add-itemsand// @facet-role: primaryaboveexport function addItem.
npx facet lintnpx facet calibrate
lint ends with 4 record(s), 4 anchor(s) checked — 0 error(s). The measurement looks like this:


Scenarios per record are inside the band now. records per capability still shows 1 below: discount codes are the only record in their capability. That is fine for a shop this size; it becomes a question once the capability should hold more.
Commit the split in one change, so the history shows where each scenario went:
git add docs srcgit commit -m "Split cart-and-checkout into add-items, shipping-fee and place-order"
Step 6If the check says something else
is active with a single contract scenario: the opposite problem. A record with one behaviour is usually a scenario of the record above it. Fold it in, or write the cases it is missing.declares 13 contract scenarios(or another number above twelve): the record describes an area. Split it as in steps 3 to 5.neither HEAD:… nor the working tree has checkout/cart/cart-and-checkout: the split is already committed, soHEADno longer has the old record. Pass the commit before it, for example--from HEAD~1.@facet: tag references "…", which has no recordafter the split: a comment in the code still names the old id. Change it to one of the new ids.
For more on keeping a growing product understandable, read Nobody wants to touch the pricing logic. And everyone has to, eventually.