<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/optimizing-claude-code-s-xcode-build-token-usage-npp0rh5az" -->

---
title: Optimizing Claude Code's Xcode build token usage | daily.dev
description: A practical tutorial for reducing Claude Code's token usage when building Xcode projects, based on Antoine van der Lee's article on token reduction in AI...
canonical: https://daily.dev/posts/optimizing-claude-code-s-xcode-build-token-usage-npp0rh5az
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Optimizing Claude Code's Xcode build token usage | daily.dev
og:description: A practical tutorial for reducing Claude Code's token usage when building Xcode projects, based on Antoine van der Lee's article on token reduction in AI...
og:url: https://daily.dev/posts/optimizing-claude-code-s-xcode-build-token-usage-npp0rh5az
og:image: https://api.daily.dev/og/posts/nPP0rH5Az.png
og:image:alt: Optimizing Claude Code's Xcode build token usage
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.

# Optimizing Claude Code's Xcode build token usage

**[Daniel Saidi](https://daily.dev/sources/danielsaidi)** · 3 min read · 0 upvotes · 0 comments

## Summary

A practical tutorial for reducing Claude Code's token usage when building Xcode projects, based on Antoine van der Lee's article on token reduction in AI coding agents. It shows a Python PreToolUse hook script that rewrites xcodebuild, swift build, and swift test commands to pipe their output through the xcsift tool, compressing verbose Xcode build output into a compact format that preserves errors, warnings, and test results. Includes the full hook script and the settings.json configuration needed to register it in Claude Code.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://danielsaidi.com/blog/2026/09/30/optimizing-claude-code-s-xcode-build-token-usage>

## Questions this post answers

### How do I reduce Claude Code's token usage when building Xcode projects?

Pipe xcodebuild, swift build, and swift test output through xcsift, a tool that compresses verbose Xcode build output into a compact format while keeping errors, warnings, and test results. Since agents often ignore instructions to use it manually, a Claude Code PreToolUse hook script can automatically rewrite matching Bash commands to route through xcsift with set -o pipefail so failures still get reported.

_daily.dev surfaces practical workflow tweaks like this for developers optimizing AI coding agent costs._

### How do I install xcsift for compressing Xcode build output?

Install xcsift via Homebrew with the command brew install xcsift. It filters xcodebuild, swift build, and swift test output down to errors, warnings, and test results, cutting the noise that otherwise wastes tokens when an AI coding agent reads raw build logs.

_Developers wiring up leaner Xcode toolchains often track setup tips like this on daily.dev._

### How do I set up a PreToolUse hook in Claude Code to automatically rewrite Bash build commands?

Add a PreToolUse hook matching the Bash tool in ~/.claude/settings.json that runs a Python script (e.g. python3 ~/.claude/hooks/xcode-output.py) with a timeout of 5 seconds. The script inspects tool_input.command, rewrites safe xcodebuild or swift build/test commands to pipe through xcsift, and leaves anything with existing formatters, pipes, or redirects untouched.

_For developers customizing Claude Code hooks, daily.dev collects hands-on configuration walkthroughs like this._

## 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 - 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
- [Maximize AI Efficiency: Reduce Token Use in Claude Pro](https://daily.dev/posts/maximize-ai-efficiency-reduce-token-use-in-claude-pro-vwm1wdmka) · Sergio Lema · 1 upvotes · 0 comments
- [Why use so many tokens when a few do the trick?](https://daily.dev/posts/why-use-so-many-tokens-when-a-few-do-the-trick--uvekb2vuw) · Product Hunt · 4 upvotes · 1 comments

---

Tags: [#swift](https://daily.dev/tags/swift), [#claude-code](https://daily.dev/tags/claude-code), [#xcode](https://daily.dev/tags/xcode), [#context-engineering](https://daily.dev/tags/context-engineering)

[View this post on daily.dev](https://daily.dev/posts/optimizing-claude-code-s-xcode-build-token-usage-npp0rh5az)

```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":"Optimizing Claude Code's Xcode build token usage","url":"https://daily.dev/posts/optimizing-claude-code-s-xcode-build-token-usage-npp0rh5az","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/optimizing-claude-code-s-xcode-build-token-usage-npp0rh5az"},"datePublished":"2026-09-30T06:41:02.230Z","dateModified":"2026-10-05T19:37:57.340Z","description":"A practical tutorial for reducing Claude Code's token usage when building Xcode projects, based on Antoine van der Lee's article on token reduction in AI...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/18e27465277456a8b48957ec518ac7b0?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/18e27465277456a8b48957ec518ac7b0?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Daniel Saidi","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":"Daniel Saidi","logo":"https://media.daily.dev/image/upload/s--RRuTMOCm--/f_auto,q_auto/v1783235599/logos/danielsaidi?_a=BAMAMicg0","url":"https://daily.dev/sources/danielsaidi"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/optimizing-claude-code-s-xcode-build-token-usage-npp0rh5az","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"swift,claude-code,xcode,context-engineering","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Daniel Saidi","item":"https://daily.dev/sources/danielsaidi"},{"@type":"ListItem","position":3,"name":"Optimizing Claude Code's Xcode build token usage"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/optimizing-claude-code-s-xcode-build-token-usage-npp0rh5az#faq","mainEntity":[{"@type":"Question","name":"How do I reduce Claude Code's token usage when building Xcode projects?","acceptedAnswer":{"@type":"Answer","text":"Pipe xcodebuild, swift build, and swift test output through xcsift, a tool that compresses verbose Xcode build output into a compact format while keeping errors, warnings, and test results. Since agents often ignore instructions to use it manually, a Claude Code PreToolUse hook script can automatically rewrite matching Bash commands to route through xcsift with set -o pipefail so failures still get reported. daily.dev surfaces practical workflow tweaks like this for developers optimizing AI coding agent costs."}},{"@type":"Question","name":"How do I install xcsift for compressing Xcode build output?","acceptedAnswer":{"@type":"Answer","text":"Install xcsift via Homebrew with the command brew install xcsift. It filters xcodebuild, swift build, and swift test output down to errors, warnings, and test results, cutting the noise that otherwise wastes tokens when an AI coding agent reads raw build logs. Developers wiring up leaner Xcode toolchains often track setup tips like this on daily.dev."}},{"@type":"Question","name":"How do I set up a PreToolUse hook in Claude Code to automatically rewrite Bash build commands?","acceptedAnswer":{"@type":"Answer","text":"Add a PreToolUse hook matching the Bash tool in ~/.claude/settings.json that runs a Python script (e.g. python3 ~/.claude/hooks/xcode-output.py) with a timeout of 5 seconds. The script inspects tool_input.command, rewrites safe xcodebuild or swift build/test commands to pipe through xcsift, and leaves anything with existing formatters, pipes, or redirects untouched. For developers customizing Claude Code hooks, daily.dev collects hands-on configuration walkthroughs like this."}}]}
```

