Repository navigation
feat(scripts): add :agent variants for running tests (and other slow commands) - #832
Conversation
Implementer subagents currently pipe heavy gates (pnpm test:packages, test:integration, build, lint, fixtures:check, turbo typecheck) directly to tail/grep, which discards the rest of the output and swallows the exit code. The next question about the output forces a full re-run. Observed in one Drive session: 4× test:packages, 4× test:integration, 11× fixtures:check, 3× turbo typecheck --force in the same window — ~25 min of pure re-run waste, in addition to CPU contention with other agents. New rule: log gate output to a wip/ file with captured exit code, grep the file. Re-run only the failing test file with --filter. Drop reflexive turbo --force. Bump the alwaysApply footprint thresholds (525→565 lines, 30000→31500 bytes) to fit the new rule. Co-authored-by: Claude Opus 4.7 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
📝 WalkthroughWalkthroughAdds a new Changesrunning-tests agent rule and :agent scripts
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
size-limit report 📦
|
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/extension-supabase
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
The rulecard is for agents; everything an agent does is "programmatic consumption". Recommending --reporter=json for that case framed grep as a fallback, but greppable text is what agents actually want from gate output. Drop the line. Co-authored-by: Claude Opus 4.7 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
"gate" is a banned word in plain-English style guidance — it conveys nothing a fresh reader can act on. Rename run-gates-once → capture-slow-command-output and rewrite the rule body to describe what the commands actually are: long-running test/build/lint commands whose output should be saved to a file and read from there, not re-run to re-filter. README entries updated. Symlink trees regenerated by pnpm rules:sync. Co-authored-by: Claude Opus 4.7 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Read the rule with the eyes of an agent mid-task. Fixes the gaps an agent following it literally would still trip on: - The rule's namesake "don't" (re-running to refine a filter) was bullet #2; promote it to #1. - "Don't pass --force to turbo" left the right thing unsaid; name the cached invocation (pnpm turbo typecheck plain). - The recipe captured the exit code but never told the agent to read it back; add the tail step plus a note for the crash-before-tests case (log has no FAIL lines). - The re-run-after-a-fix case was unspecified; say to overwrite the same file with >. - wip/ was presented as a magic convention; note that it's gitignored at the repo root. - Scope-limit the rule explicitly to the listed slow commands; tell agents short commands run normally. - Replace the orphaned "if a pipe is unavoidable" line with a worked tee + PIPESTATUS example. - Drop the meta "largest waste of agent time" framing — it's for the reviewer, not the executing agent. Bytes threshold bumped 31500 → 32000 to fit the richer recipe; lines threshold unchanged. Co-authored-by: Claude Opus 4.7 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
"capture slow command output" is bureaucratic abstraction. The rule is about running tests — that is the primary thing agents do that hits this — with build/lint/typecheck/fixtures as adjacent cases. Name it that, lead the body with that, and let the other commands appear as the list of things this same recipe applies to. Rule heading: "Running tests" First sentence: "When you run tests, save the output to a file and read the file." Co-authored-by: Claude Opus 4.7 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…-tests rule Bake the "save output to a file" pattern into package.json instead of asking agents to remember it. Eight new scripts: - test:packages:agent, test:integration:agent, test:e2e:agent - build:agent, typecheck:agent - lint:agent, lint:deps:agent, fixtures:check:agent Each wraps its canonical sibling with: mkdir -p wip; pnpm <name> > wip/<name>.log 2>&1; status=$?; echo $status > wip/<name>.exit; exit $status The script exits with the underlying command's status, so the harness still sees pass/fail. POSIX-portable; no helper script needed. Rule rewritten with the four sections an agent actually needs: 1. Run a test suite (table of :agent commands and what they do) 2. Run one package's tests 3. Rerun a specific failing test (by file, by name) 4. Find specific failures in the captured output + Don't list Footprint thresholds bumped (565 → 605 lines, 32000 → 32500 bytes) to fit the richer rule. Co-authored-by: Claude Opus 4.7 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wip/ now exists in the repo via wip/.gitkeep, with its contents gitignored (/wip/* + !/wip/.gitkeep). That removes the only reason the :agent scripts needed mkdir -p wip; up front — the directory is always there. Each script is one shell statement now: pnpm <name> > wip/<name>.log 2>&1; status=$?; echo $status > wip/<name>.exit; exit $status Co-authored-by: Claude Opus 4.7 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Run-full → fix → run-full again was overwriting the first run's log, so the original failure list was gone when the agent wanted to compare. Now each :agent run writes to wip/<name>.<YYYYMMDD-HHMMSS>.<pid>.log and a sibling .exit, and wip/<name>.log / wip/<name>.exit are symlinks updated to point at the latest run. The agent's read path is unchanged (`cat wip/<name>.exit`, `grep ... wip/<name>.log` follow the symlinks), and historical runs are preserved next to them. The PID suffix disambiguates same-second runs from concurrent shells. Rule section 1 updated to describe the layout. Co-authored-by: Claude Opus 4.7 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Each :agent script now prints "log: wip/<name>.<ts>.<pid>.log" as its first line of output, and the agent uses that exact path for the rest of the workflow. No symlinks; no implicit "latest" abstraction. The read path is whatever the script just told you — extremely clear. History is still preserved automatically because every run gets its own timestamped + PID-suffixed filename. Rule sections 1 and 4 updated; bytes threshold bumped 32500 → 33000. Co-authored-by: Claude Opus 4.7 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
At a glance
$ pnpm test:packages:agent log: wip/test-packages.20260615-190441.32317.log $ grep -nE " FAIL |Test Files" wip/test-packages.20260615-190441.32317.log …The
:agentvariant runs the canonical command, redirects its full output to a timestamped file underwip/, prints that path as its first line of output, and exits with the same status as the underlying command. The agent uses the exact path the script just announced.The decision
Every slow verification command —
test:packages,test:integration,test:e2e,build,typecheck,lint,lint:deps,fixtures:check— gets an:agentvariant. Agents use the:agentform; canonical commands are unchanged for humans and CI.Each variant writes
wip/<name>.<YYYYMMDD-HHMMSS>.<pid>.logand a sibling.exit, then prints the log path. Every run gets a unique filename so history is preserved automatically.wip/.gitkeepis committed; everything else underwip/is gitignored.A new always-apply rulecard,
.agents/rules/running-tests.mdc, documents the workflow::agentvariant).pnpm --filter <pkg> test).-t).:agentprinted).Why this matters
Sampled from one Drive session, ~90 min in a single subagent:
pnpm test:packages(~150s each) chasing the same failure listpnpm test:integrationfor the same reasonpnpm fixtures:checkre-runs grepping different slices of the same outputpnpm turbo typecheck --forcein the same minute~25 min of pure re-run waste in one subagent. The cause: piping
pnpm test:packagestotail/grep/headdiscards the rest of the output and hides the exit code (those tools return 0). The next question about the failure forces a full re-run.A rulecard alone would tell agents "redirect to a file, then grep it" — standing guidance they have to remember and apply. The
:agentscripts bake the pattern into the command. Affordance, not memory.What's in this PR
.agents/rules/running-tests.mdc(always-apply), symlinked into.cursor/rules/and.claude/rules/by the existingpnpm rules:sync.wip/.gitkeepcommitted;.gitignorenow reads/wip/*+!/wip/.gitkeep.Alternatives considered
scripts/agent-run.sh). Each:agentis one self-contained shell statement; no shared library to maintain.skills-contrib/running-tests/). Skills are procedural workflows you invoke; "always run tests this way" is standing guidance, which is what.agents/rules/*.mdcis for.wip/<name>.log→ latest run. Tried, removed. The script prints the exact log path, so the read path is unambiguous — no need for a "latest" abstraction.mkdir -p wipprefix in every script. Replaced by committingwip/.gitkeep— the directory always exists, the scripts stay short.--reporter=json) reporter on the first run. Plausible but unnecessary — everything an agent does is programmatic; the agent reads the same human-readable log a human would, andgrep/tailwork fine against it.Verification
pnpm lint:deps:agentend-to-end: printslog: wip/lint-deps.<ts>.<pid>.log, writes the log +.exit, exits with the right status.pnpm lint:rules:footprint— passes after threshold bumps.pnpm lint:rules:symlinks— symlink trees consistent.Co-authored-by: Claude Opus 4.7 [email protected]