Agent Hooks + Chunk sidecars: Stop Broken AI Code Before It Hits CI

Jun 10, 2026

AI agents write code fast, but the feedback loop usually can't keep up. In this tutorial, you'll see how to wire Chunk sidecars into your agent's hooks so basic failures get caught before they ever reach your CI pipeline.

We'll walk through the two hooks that chunk init writes automatically:

  • Pre-tool use (commit gate) runs your test suite locally before every git commit
  • Stop (finish gate) syncs your working tree to a remote Linux microVM and runs your full test suite before the agent ends its turn

Both hooks return exit 2 on failure, blocking the commit or keeping the turn open so the agent can fix its own mistakes with no manual prompting required.

Your CI pipeline still runs integration tests and security scans. The difference: it's no longer burning cycles on code that fails a basic unit test.

00:00 Intro and recap

00:21 Why use agent hooks?

00:40 The two hooks chunk init writes

01:22 Seeing the hooks in action

02:21 How both gates work in sequence

02:44 Inner loop vs. outer loop

03:03 Get started

Video | Run CI Tests Without Pushing: https://youtu.be/hE5y2eOp7Mw
Get started with CircleCI: https://circle.ci/3PSH49B
Blog post: https://circle.ci/4xlyvEU
Learn more about Chunk: https://circle.ci/4fDqIfk