add-predicate
Skill0 starsChanged 54 days agoMITView on GitHub
Add a new built-in check predicate to @codai/axiom-checks — Zod params, fail-closed run(), registry entry, profile wiring, unit + fail-closed tests, changeset. Use when a user asks for a new rule the gate should enforce ("block files over N bytes", "deny imports of X", "require a LICENSE next to package.json").
In this repository4 other files it gives its agents.
- add-golden-fixtureSkill
- add-mcp-toolSkill
- debug-apply-journalSkill
- release-axiomSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
Register it: import + add to both the named export block and BUILTIN_PREDICATES in packages/checks/src/predicates/index.ts.
- Very specific: line 34
Wire a profile: if it should run by default: add a { id, predicate, params } entry to default/strict in packages/checks/src/profile.ts.
- Very specific: line 43
New error code?: Only if a *provider* failure mode is new: append to ERROR_CODES in packages/schema/src/errors.ts first …
- Very specific: line 46
Docs: add a row to the predicate table in packages/checks/README.md (id, params, what it flags).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Add a check predicate
A predicate is a pure function (FactContext, params) → Finding[] registered by
id <group>.<name>. It never throws for a "rule violated" — that is a Finding.
It does return verdict: "error" (via AxiomError → the runner maps it) when a
fact provider cannot deliver — fail closed, never a constant pass (PLAN.md §2).
Steps
- Pick the group file in
packages/checks/src/predicates/:path.ts(path shape),content.ts(bytes),manifest.ts(set-level),deps.ts(package.json),repo.ts(existing tree),guard.ts(external). New group → new file, same shape asdeps.ts. - Define params as a
z.object({...}).strict()with defaults, then exportdefinePredicate<z.infer<typeof Params>>({ id, params, requires, run })frompackages/checks/src/types.ts.requireslists the fact providers ("manifest" | "content" | "repo" | "guard") — declare only what you read. - Implement
run(ctx, params)using helpers frompredicates/util.ts(finding(),globMatcher(),parseJsonObject()). Iteratectx.manifest.artifacts, skipop === "delete"where irrelevant, read bytes withawait ctx.facts.content(path);undefinedmeans the blob is not available → return nothing for that artifact (the runner already reports missing facts). EveryFindingneedsid,predicate,path?,messageand machine-readablefacts. - Register it: import + add to both the named export block and
BUILTIN_PREDICATESinpackages/checks/src/predicates/index.ts. The registry (packages/checks/src/registry.tsbuiltinRegistry()) picks it up; duplicate ids throwERR_INTERNALat startup. - Wire a profile if it should run by default: add a
{ id, predicate, params }entry todefault/strictinpackages/checks/src/profile.ts. Leavepermissiveminimal. - Tests in
packages/checks/src/predicates/predicates.test.ts(or a new<group>.test.ts): one passing manifest, one violating (assertfindings[0].predicateandfacts, not message text), one with a broken fact provider asserting the fail-closed verdict, and — if params carry globs/sizes — afast-checkproperty. Helpers inpackages/checks/src/test-helpers.test-helpers.ts. - New error code? Only if a provider failure mode is new: append to
ERROR_CODESinpackages/schema/src/errors.tsfirst (scripts/check-error-codes.mjsenforces it). - Docs: add a row to the predicate table in
packages/checks/README.md(id, params, what it flags). If the MCP exposes profiles viaaxiom_check,docs/reference/mcp-tools.mdneeds no change unless the tool input changed. - Changeset:
pnpm changeset→@codai/axiom-checksminor("feat(checks): add<group>.<name>predicate"). - Verify and paste output:
pnpm --filter @codai/axiom-checks test,pnpm exec biome check packages/checks,node scripts/run-guards.mjs --fast. Predicates are in the Stryker scope (stryker.config.mjs) — a test that survives mutating your comparison operator is not done.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

