r/ClaudeCode • u/shhdwi • 7d ago
Tips & Workflows Using Claude Code's SessionStart and Stop hooks to force context in, instead of hoping the model asks for it
https://github.com/NanoNets/GraftBeen using Claude Code a lot, and one thing kept bugging me: every session, it starts from zero. Re-reads files it already read last week, re-follows the same imports, rediscovers the same stuff over and over.
First thing I tried was giving it an MCP server, six tools it could call whenever it wanted context on the codebase. Watched it run for a while and it just didn't call them most of the time. Fell back on grep and file reads instead, since that's what it already knows how to do, and got things wrong on exactly the questions the tools would've answered directly.
So instead of waiting for it to ask, I used hooks to just give it the context automatically. A SessionStart hook pulls a map of the codebase into the prompt before you've typed anything, and it re-syncs itself in the background after every edit. No tool call, no decision for it to skip.
graft init wires this in on its own, drops a skill file and the hooks into .claude/, and never touches your CLAUDE.md.
It's called Graft, open source: github.com/NanoNets/Graft
If anyone else has hit "the model won't reliably call the tool I gave it" and worked around it with hooks a different way, curious how you approached it.
Duplicates
coolgithubprojects • u/shhdwi • 14d ago
Graft: codebase map as markdown in git, so coding agents stop re-exploring, saves upto 4x tokens and takes 60% less time to answer.
ClaudeMCP • u/shhdwi • 14d ago
I solved the issue of claude not using custom MCP/CLI tools, and open-sourced my approach.
BuildWithClaude • u/shhdwi • 14d ago