shared-package-criteria
What belongs in the shared package.
Agent checkAdvises by default
The rule
Agents read this text as written when they write and review code.
In a repo with several packages, never copy code from one package into another. Put it in the shared package, but only when two or more packages need it and it is a contract both sides agree on, such as constants, error codes or pure functions.
- One package needs it: put it in that package's
common/. - It depends on a library only one package uses: keep the pure part shared, and wrap it in that package.
Copies in each package drift apart, and a fix then reaches only one of them.
Examples
The agent flags code like the incorrect example and accepts code like the correct one. Each example is a small repo, because this rule looks across files. It opens on the file that matters; the other files are the repo around it.
Incorrect
packagesfrontendsrcbillingsharedsrcbillingutils
import { getInvoiceRowClass } from '@scope/shared/billing/utils/getInvoiceRowClass';export const renderInvoiceRow = getInvoiceRowClass;
Correct
packagesfrontendsrcbillingsharedsrcpermissionsutils
export const getInvoiceRowClass = () => 'row';
Configure
- Block
"blocking"Stops a run when a file the run changed breaks the rule. - AdviseDefault
"advisory"Reports it and hands it to the refactor agent. Never stops a run. - Off
"off"Not checked. Use it when your own linter already enforces the rule.
Add this to your lightsout.config.json, then change the value.
{"standards-rule-settings": {"shared-package-criteria": "advisory"}}