SessionStart Hook Feeds Claude Code Failing Tests Before Its First Turn

A developer describes a way to make Claude Code aware of failing tests from the outset. Claude Code's SessionStart hook can add plain-text output as context before the first prompt. A short script can run fast pytest tests, keep only the failures, and pass that list to Claude. The author notes that output is capped at 10,000 characters and that the wording should be factual rather than phrased as commands, to avoid triggering prompt-injection defenses. The approach uses a standard-library-only Python script saved in the project's .claude/hooks directory.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in