SitePoint17 min readtutorialintermediate
Optimizing GitHub Actions for Agent PRs: Speculative Test Slicing and AST Impact Analysis
Summary
A step‑by‑step guide for handling the flood of pull requests generated by code‑generation agents. It builds a TypeScript CLI that uses ts‑morph to do AST‑level change‑impact analysis, maps affected symbols to tests, and runs only those tests in a “speculative” GitHub Actions job while a full‑suite verification runs in the background. The article includes concrete CLI code, dependency choices, con…
- Agent‑authored PRs can generate dozens of narrow diffs per day, making full‑suite CI impractical.
- AST impact analysis (via ts‑morph) can identify exported symbols changed in a diff and resolve their reverse dependency graph to find truly affected files.
- Map impacted source files to test files (co‑located or glob‑matched) and run only that slice as the blocking CI check.
- Run a full‑suite verification as a non‑blocking job to catch the rare false‑negative; if it fails, apply a label and alert the team.
CI cost and latency are major bottlenecks for teams that rely on autonomous coding agents. By slicing tests based on precise AST impact, teams can keep feedback loops fast, control cloud‑runner spend, and still retain safety via a background full‑suite run. The approach is reusable across TypeScrip…
6/10





