Lint failures in CI are a familiar friction: the build goes red, someone reads the log, fixes a few lines, and pushes again. Headless Claude can take the first swing at that loop so the easy fixes never reach a person.
The headless building block
Headless mode with JSON output is the basis for CI automation. In a pipeline step, run your linter, and if it fails, hand the problem to Claude.
npm run lint || claude -p "Fix the lint errors in this project. Run the linter to confirm they pass." \
--output-format json
Giving Claude the linter as its own check matters. It can run the command, see what is still broken, and iterate until the check is clean, rather than guessing once and stopping.
Scope the permissions tightly
CI has no human to answer prompts, so decide up front what Claude may do. Prefer narrow permission rules over blanket access. Allow the editing and the specific commands the job needs, and nothing more.
claude -p "Fix lint errors and re-run the linter." \
--permission-mode acceptEdits \
--output-format json
Use acceptEdits so file edits go through without a prompt while other actions still follow your rules. Reserve wider modes for jobs you fully trust.
Read the result in your pipeline
With --output-format json, your CI script can parse the response and decide what to do next: commit the fix, open a follow-up, or fail loudly if nothing worked.
Keep a human gate
Let Claude fix and push to a branch, but keep the merge behind a normal review. The goal is to remove the boring round-trips, not to let unreviewed changes flow to main. Automate the fix, keep the judgment.
Comments
Be the first to comment.