@keboola/agent-precheck
v0.2.0
Published
Portable pre-push enforcement CLI for Keboola UI platform consumers — runs formatting and lint checks consistently across any repo.
Readme
@keboola/agent-precheck
A portable pre-push enforcement CLI for the Keboola UI platform. Runs the same formatting and lint gates everywhere — keboola/ui, other Keboola repos, AI-agent-generated apps — so a single command verifies that a working tree is push-ready.
Why this exists
PR template checklists and "remember to run lint" agent instructions are descriptive but unverified. Agents (and humans) push PRs that fail CI on oxfmt or oxlint despite ticking every box. This package replaces the checklist with a single command that mechanically applies fixes and reports a hard pass/fail.
The CLI is platform-distributed — published to npm so any consumer of @keboola/design or @keboola/api-client can run the same gate without copying scripts around.
Install
Already vendored as a workspace in keboola/ui. Outside this monorepo:
yarn add -D @keboola/agent-precheckOr run ad-hoc without installing:
npx @keboola/agent-precheckUsage
# Default: fix mode on files changed vs origin/main + working tree
yarn precheck
# CI mode: no fixes, exit non-zero on any issue
yarn precheck --check
# Only files currently staged
yarn precheck --staged
# Every tracked file (slow; for first-run cleanups)
yarn precheck --all
# Suppress per-tool stdout
yarn precheck --quiet
# Skip the workspace-wide checks individually
yarn precheck --no-deps-check
yarn precheck --no-knipWhat it runs (in order, fail-fast)
oxfmt— apply formatting.oxlint --fix— apply lint auto-fix.oxfmt --check— verify formatting is clean.oxlint— verify lint is clean.syncpack lint— verify dependency versions are consistent (only when at least onepackage.jsonis in the changed-file set; only ifsyncpackis installed).knip— verify no unused exports / deps / files (only ifknipis installed).
Any auto-fixed file is re-git added so git push ships the fixes.
Always-ignored paths
The following directories are filtered from the discovered file set regardless of .gitignore state — universal JS-project artifacts that no project meaningfully lints:
node_modules/ dist/ build/ out/ .next/
.turbo/ .yarn/ coverage/ storybook-static/The match is both leading-prefix (node_modules/foo) and any internal segment (packages/foo/node_modules/bar) so monorepo workspace node_modules are also skipped. Belt-and-suspenders against the common "fresh git init + npm install without .gitignore" footgun where git ls-files --others --exclude-standard would otherwise return every file under node_modules/**.
How binaries are resolved
- Walk up
node_modules/.bin/fromcwd(handles monorepo + worktree cases). - For
oxfmtandoxlint: fall back tonpx --yes --package <name>if not found locally. Slower on first run; cached afterward. - For
syncpackandknip: skip gracefully (with a one-line(skipped: not installed)note) if not found locally. No npx fallback — auto-installing heavier deps in repos that deliberately opt out is a footgun. Use--no-deps-check/--no-knipto suppress the "skipped" line.
This means the CLI works in:
- This monorepo (all four binaries live in root
node_modules). - Other repos that
yarn add -Dwhichever subset they use. - Bare working trees with only Node and network access (oxfmt/oxlint via npx fallback; syncpack/knip skipped with a
(skipped: not installed)note, suppressible via--quietor--no-deps-check/--no-knip).
Out of scope (for now)
brand-auditintegration — added when the audit CLI is stable.- Pre-push git hook installation — the CLI is the contract; whoever wires it into a hook gets the gate.
- CI integration to run
--checkearly in the workflow — separate follow-up.
Failure mode
Exit code 1 with an explicit message:
❌ agent-precheck failed: format issues remain, lint issues remain.
Fix the issues above and re-run. Do not push around them.Reference
- Linear UT-3992 — initial release issue.
- Platform epic: https://linear.app/keboola/issue/UT-3919
