The best way to control Claude Code, Codex and more from any computer or phone
perf(dev): knip:check runs its two passes side by side (34 s → 26 s median on 4 CPUs) (#30737)
Pyseph committed
Nov 6, 2026 at 05:37 UTC
b60a89ff3b4bfa389b9d180c2aa48c1d9db6e1fd
5 files changed
+37
-9
docs/operations/development.md
+1
-1
@@ -233,7 +233,7 @@ Windows investigation while that suite is not a required gate.
233
234
### Unused code
235
236
-`vp run knip:check` checks unused files and dependencies across the repo, then
236
+`vp run knip:check` checks unused files and dependencies across the repo and, at the same time,
237
unused runtime exports in `apps/server`, `apps/desktop`, `apps/web`, and every internal package under
238
`packages/`. CI enforces both checks.
239
Exported types and Effect schemas are allowed without consumers. The schema preprocessor
package.json
+3
-1
@@ -31,7 +31,9 @@
31
"report:renders": "node scripts/render-metrics.ts",
32
"lint": "vp lint --report-unused-disable-directives",
33
"knip": "knip --preprocessor ./scripts/knip-schemas.ts",
34
- "knip:check": "knip --include files,dependencies --no-config-hints && knip --workspace apps/server --workspace apps/desktop --workspace apps/web --workspace packages/client-runtime --workspace packages/contracts --workspace packages/effect-acp --workspace packages/effect-codex-app-server --workspace packages/shared --workspace packages/ssh --workspace packages/tailscale --workspace packages/provider-core --workspace packages/provider-acp --workspace packages/provider-acp-registry --workspace packages/provider-testing --workspace packages/provider-pi --workspace packages/provider-muse --workspace packages/provider-opencode --workspace packages/provider-cursor --workspace packages/provider-fx --workspace packages/provider-grok --workspace packages/provider-kiro --workspace packages/secret-provider-core --workspace packages/secret-provider-definitions --workspace packages/secret-provider-onepassword --workspace packages/source-control-core --workspace packages/source-control-definitions --workspace packages/source-control-azure-devops --workspace packages/source-control-bitbucket --workspace packages/source-control-forgejo --workspace packages/source-control-gitcafe --workspace packages/source-control-github --workspace packages/source-control-gitlab --workspace packages/source-control-testing --exports --preprocessor ./scripts/knip-schemas.ts --no-config-hints",
34
+ "knip:check": "vp run knip:check:all",
35
+ "knip:check:files": "knip --include files,dependencies --no-config-hints",
36
+ "knip:check:exports": "knip --workspace apps/server --workspace apps/desktop --workspace apps/web --workspace packages/client-runtime --workspace packages/contracts --workspace packages/effect-acp --workspace packages/effect-codex-app-server --workspace packages/shared --workspace packages/ssh --workspace packages/tailscale --workspace packages/provider-core --workspace packages/provider-acp --workspace packages/provider-acp-registry --workspace packages/provider-testing --workspace packages/provider-pi --workspace packages/provider-muse --workspace packages/provider-opencode --workspace packages/provider-cursor --workspace packages/provider-fx --workspace packages/provider-grok --workspace packages/provider-kiro --workspace packages/secret-provider-core --workspace packages/secret-provider-definitions --workspace packages/secret-provider-onepassword --workspace packages/source-control-core --workspace packages/source-control-definitions --workspace packages/source-control-azure-devops --workspace packages/source-control-bitbucket --workspace packages/source-control-forgejo --workspace packages/source-control-gitcafe --workspace packages/source-control-github --workspace packages/source-control-gitlab --workspace packages/source-control-testing --exports --preprocessor ./scripts/knip-schemas.ts --no-config-hints",
37
"knip:production": "knip --production --preprocessor ./scripts/knip-schemas.ts",
38
"lint:mobile": "node scripts/mobile-native-static-check.ts",
39
"mobile:install": "node scripts/mobile-native-client.ts ensure",
scripts/check-changed.test.ts
+10
-2
@@ -319,7 +319,13 @@ function launcherFixture() {
319
write("pnpm-workspace.yaml", "packages:\n - packages/*\n");
320
write(
321
"package.json",
322
- JSON.stringify({ type: "module", scripts: { "knip:check": "knip --include files" } }),
322
+ JSON.stringify({
323
+ type: "module",
324
+ scripts: {
325
+ "knip:check:files": "knip --include files",
326
+ "knip:check:exports": "knip --exports",
327
+ },
328
+ }),
329
);
330
write("packages/example/package.json", JSON.stringify({ name: "example" }));
331
const source = "packages/example/space & (draft) %PATH% ! 研究.ts";
@@ -426,7 +432,9 @@ it("lints an Astro component and runs knip when only it changed", () => {
432
"--no-error-on-unmatched-pattern",
433
page,
434
]);
429
- expect(calls.some(({ args }) => args[0] === "exec" && args[1] === "knip")).toBe(true);
435
+ const commands = calls.map(({ args }) => args);
436
+ expect(commands).toContainEqual(["exec", "knip", "--include", "files"]);
437
+ expect(commands).toContainEqual(["exec", "knip", "--exports"]);
438
});
439
440
it.each(["install", "lint"])("reports a failing %s step with its output", (step) => {
scripts/check-changed.ts
+13
-4
@@ -108,7 +108,14 @@ const CacheEntry = Schema.fromJsonString(
108
const decodeCacheEntry = Schema.decodeEffect(CacheEntry);
109
const encodeCacheEntry = Schema.encodeEffect(CacheEntry);
110
const decodeRootPackageJson = Schema.decodeEffect(
111
- Schema.fromJsonString(Schema.Struct({ scripts: Schema.Struct({ "knip:check": Schema.String }) })),
111
+ Schema.fromJsonString(
112
+ Schema.Struct({
113
+ scripts: Schema.Struct({
114
+ "knip:check:files": Schema.String,
115
+ "knip:check:exports": Schema.String,
116
+ }),
117
+ }),
118
+ ),
119
);
120
121
const collectBytes = (stream: Stream.Stream<Uint8Array, PlatformError.PlatformError>) =>
@@ -370,14 +377,16 @@ const checkChanged = Effect.fn("checkChanged")(function* (input: {
377
const runKnip = files.some(
378
(file) => CODE.test(file) || path.basename(file) === "package.json" || file === "knip.jsonc",
379
);
373
- // CI runs knip:check as one script of `knip ... && knip ...` passes. The passes
380
+ // CI runs knip:check as a task that depends on one script per pass. The passes
381
// do not depend on each other, so they run side by side here.
382
const rootPackage = yield* fs
383
.readFileString(inRoot("package.json"))
384
.pipe(Effect.flatMap(decodeRootPackageJson), Effect.orDie);
378
- const knipCheck = rootPackage.scripts["knip:check"];
385
const knipPasses: Array<Array<string>> = [];
380
- for (const command of knipCheck.split(" && ")) {
386
+ for (const command of [
387
+ rootPackage.scripts["knip:check:files"],
388
+ rootPackage.scripts["knip:check:exports"],
389
+ ]) {
390
const [bin, ...args] = command.trim().split(/\s+/);
391
if (bin !== "knip" || /["'$\\|;&<>]/.test(command)) {
392
return yield* Effect.fail(`check:changed cannot split knip:check: ${command}`);
vite.config.ts
+10
-1
@@ -88,7 +88,16 @@ const taskCacheConfig = {
88
export default defineConfig({
89
run: {
90
cache: taskCacheConfig,
91
- tasks: cachedTestTasks(process.env.T3_CACHED_TESTS),
91
+ tasks: {
92
+ ...cachedTestTasks(process.env.T3_CACHED_TESTS),
93
+ // The two knip passes read the same files and write nothing, so they run side by side.
94
+ // The `knip:check` script runs this task, so `vp run knip:check` and `pnpm run knip:check` both use it.
95
+ "knip:check:all": {
96
+ command: 'node -e ""',
97
+ dependsOn: ["knip:check:files", "knip:check:exports"],
98
+ cache: false,
99
+ },
100
+ },
101
},
102
resolve: {
103
alias: {