<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/graft-for-claude-code-cutting-token-use-by-42-in-practice-h3xjkagy1" -->

---
title: Graft for Claude Code: Cutting Token Use by 42% in Practice
description: Graft is an open-source hooks framework for Claude Code that intercepts tool calls at the shell level to strip redundant context before it reaches the API. In...
canonical: https://daily.dev/posts/graft-for-claude-code-cutting-token-use-by-42-in-practice-h3xjkagy1
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Graft for Claude Code: Cutting Token Use by 42% in Practice | daily.dev
og:description: Graft is an open-source hooks framework for Claude Code that intercepts tool calls at the shell level to strip redundant context before it reaches the API. In...
og:url: https://daily.dev/posts/graft-for-claude-code-cutting-token-use-by-42-in-practice-h3xjkagy1
og:image: https://api.daily.dev/og/posts/h3xJKAGy1.png
og:image:alt: Graft for Claude Code: Cutting Token Use by 42% in Practice
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Graft for Claude Code: Cutting Token Use by 42% in Practice

**[SitePoint](https://daily.dev/sources/sitepoint)** · 18 min read · 2 upvotes · 0 comments

## Summary

Graft is an open-source hooks framework for Claude Code that intercepts tool calls at the shell level to strip redundant context before it reaches the API. In internal SWE-bench Verified benchmarks it cut mean token usage from 8,070 to 4,650 tokens per task (a 42% reduction), lowered cost per task from $0.0429 to $0.0292, and improved the benchmark score from 54% to 66%. The piece walks through how the hook pipeline works (PreToolUse, PostToolUse, Notification, optional PreOutput), installation and configuration options (maxGrepLines, deduplicationWindow, contextBudget, verbosity), writing custom filter hooks, and caveats: savings range from roughly 10% to over 50% depending on task size, aggressive settings can degrade output quality, and Graft only works with the Claude Code CLI, not wrapper tools like Cursor or Copilot.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.sitepoint.com/graft-claude-code-hooks-token-optimization>

## Questions this post answers

### How much can Graft reduce token usage in Claude Code tasks?

Graft reduced mean token usage per task from 8,070 to 4,650 tokens, a 42% reduction, in internal SWE-bench Verified benchmarks, lowering cost per task from $0.0429 to $0.0292 (about 32% cheaper due to differing input/output token pricing). Real-world savings range from roughly 10% on small single-file tasks to over 50% on large multi-file monorepo tasks.

_Developers weighing Claude Code cost optimizations can track tools like Graft and benchmark results on daily.dev._

### What are the prerequisites for installing Graft with Claude Code?

Graft requires the Claude Code CLI installed and authenticated, Node.js 18.x LTS or later (its hook scripts run on Node.js, tested with 18.20.x), Git for cloning the repository, and macOS or Linux, since Windows path handling for the ~/.claude/ config directory is unverified.

_Anyone setting up Claude Code tooling can find setup checklists like this through daily.dev._

### Which Claude Code hook points does Graft use to trim token usage?

Graft targets PreToolUse, which fires before a tool call executes; PostToolUse, which fires after execution with the tool's output; Notification, for informational events used in logging; and optionally PreOutput if supported by the Claude Code version in use. These hooks deduplicate repeated file reads, trim verbose grep output to relevant matches, and enforce a per-call token budget.

_Developers building on Claude Code's hook system can keep up with implementation patterns via daily.dev._

## Similar posts on daily.dev

- [7 ways I make Claude Code use fewer tokens without hurting the results](https://daily.dev/posts/7-ways-i-make-claude-code-use-fewer-tokens-without-hurting-the-results-s1mmfwq7r) · XDA Developers · 1 upvotes · 0 comments
- [GitHub Slashes Agent Workflow Token Spend up to 62% with Daily Audits and MCP Pruning](https://daily.dev/posts/github-slashes-agent-workflow-token-spend-up-to-62-with-daily-audits-and-mcp-pruning-mzxegesce) · InfoQ · 0 upvotes · 0 comments
- [GitHub - drona23/claude-token-efficient: Universal CLAUDE.md - cut Claude output tokens by 63%. Drop-in. No code changes.](https://daily.dev/posts/github---drona23-claude-token-efficient-universal-claude-md---cut-claude-output-tokens-by-63-drop-cba3nnscu) · Hacker News · 3 upvotes · 0 comments
- [Ponytail Skill for Claude Code: Does It Really Cut Tokens](https://daily.dev/posts/ponytail-skill-for-claude-code-does-it-really-cut-tokens-cg3wamcrt) · JetBrains · 1 upvotes · 0 comments

---

Tags: [#ai](https://daily.dev/tags/ai), [#llm](https://daily.dev/tags/llm), [#nodejs](https://daily.dev/tags/nodejs), [#claude-code](https://daily.dev/tags/claude-code), [#context-engineering](https://daily.dev/tags/context-engineering)

[View this post on daily.dev](https://daily.dev/posts/graft-for-claude-code-cutting-token-use-by-42-in-practice-h3xjkagy1)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Graft for Claude Code: Cutting Token Use by 42% in Practice","url":"https://daily.dev/posts/graft-for-claude-code-cutting-token-use-by-42-in-practice-h3xjkagy1","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/graft-for-claude-code-cutting-token-use-by-42-in-practice-h3xjkagy1"},"datePublished":"2026-08-20T22:47:39.714Z","dateModified":"2026-09-14T06:56:13.650Z","description":"Graft is an open-source hooks framework for Claude Code that intercepts tool calls at the shell level to strip redundant context before it reaches the API. In...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/dd7624aded7c95751aa2c696e90d16b7?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/dd7624aded7c95751aa2c696e90d16b7?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"SitePoint","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"SitePoint","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/sitepoint","url":"https://daily.dev/sources/sitepoint"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/graft-for-claude-code-cutting-token-use-by-42-in-practice-h3xjkagy1","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai,llm,nodejs,claude-code,context-engineering","timeRequired":"PT18M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"SitePoint","item":"https://daily.dev/sources/sitepoint"},{"@type":"ListItem","position":3,"name":"Graft for Claude Code: Cutting Token Use by 42% in Practice"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/graft-for-claude-code-cutting-token-use-by-42-in-practice-h3xjkagy1#faq","mainEntity":[{"@type":"Question","name":"How much can Graft reduce token usage in Claude Code tasks?","acceptedAnswer":{"@type":"Answer","text":"Graft reduced mean token usage per task from 8,070 to 4,650 tokens, a 42% reduction, in internal SWE-bench Verified benchmarks, lowering cost per task from $0.0429 to $0.0292 (about 32% cheaper due to differing input/output token pricing). Real-world savings range from roughly 10% on small single-file tasks to over 50% on large multi-file monorepo tasks. Developers weighing Claude Code cost optimizations can track tools like Graft and benchmark results on daily.dev."}},{"@type":"Question","name":"What are the prerequisites for installing Graft with Claude Code?","acceptedAnswer":{"@type":"Answer","text":"Graft requires the Claude Code CLI installed and authenticated, Node.js 18.x LTS or later (its hook scripts run on Node.js, tested with 18.20.x), Git for cloning the repository, and macOS or Linux, since Windows path handling for the ~/.claude/ config directory is unverified. Anyone setting up Claude Code tooling can find setup checklists like this through daily.dev."}},{"@type":"Question","name":"Which Claude Code hook points does Graft use to trim token usage?","acceptedAnswer":{"@type":"Answer","text":"Graft targets PreToolUse, which fires before a tool call executes; PostToolUse, which fires after execution with the tool's output; Notification, for informational events used in logging; and optionally PreOutput if supported by the Claude Code version in use. These hooks deduplicate repeated file reads, trim verbose grep output to relevant matches, and enforce a per-call token budget. Developers building on Claude Code's hook system can keep up with implementation patterns via daily.dev."}}]}
```

