{
  "id": 19056461,
  "title": "A SessionStart Hook That Hands Claude Code the Failing Tests Before Its First Turn",
  "url": "https://urgent.news/2026/11/09/a-sessionstart-hook-that-hands-claude-code-the-failing-tests-before",
  "topic": "ai",
  "section": "AI",
  "published": "2026-11-09T01:01:20.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/gabrielanhaia/a-sessionstart-hook-that-hands-claude-code-the-failing-tests-before-its-first-turn-3gl3"
  },
  "original_language": "en",
  "account": "In the case described, a failing test suite caused the CI build to turn red. When a fresh Claude Code session begins, it must run the suite and read the output to learn about the errors before the developer can even start working on the issue. To avoid this delay, a SessionStart hook has been implemented. This hook runs during the initial setup of the Claude Code session and performs the following actions:\n\n1. It uses pytest to execute only the fast tests, excluding any marked as \"slow\".\n2. The hook keeps the output limited to the first 200 characters of each failure or error message to reduce the size of the information passed to Claude Code.\n3. The hook only retries executing the tests if they exceed the set budget of 45 seconds, which is the maximum timeout allowed for the hook.\n4. If the tests pass, it informs Claude that the fast tests have passed during the session start.\n5. If there are failing tests, it lists the failing tests (up to a maximum of 15) and prints up to 200 characters from each failure message. If there are more than 15 failures, it indicates that there are additional failing tests.\n6. If pytest exits with a non-zero return code without listing any failures, the hook informs Claude of the exit code and notes that no failures were listed.\n\nBy running this script as a SessionStart hook, Claude Code can be provided with the list of failing tests before the developer even begins typing, saving valuable time and effort in debugging and fixing the issues.",
  "summary": "Book: AI Agents Pocket Guide The series: Pocket Guides for Developers — 8 short books on agents, RAG, prompts, observability, events, databases and system design — the whole series My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub CI went red over the weekend. Three checkout tests fail, and you know their names. A…",
  "key_points": [
    "SessionStart hook runs during Claude Code session setup",
    "Executes fast tests only, excludes slow ones",
    "Limits output to first 200 characters of failure messages"
  ],
  "editors_take": "Automating the initial diagnostic phase eliminates the manual overhead of error reporting, allowing the AI to begin debugging immediately upon session startup to accelerate the software development lifecycle.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}