SShortSingh.
Back to feed

Claude Code Hooks: Which Events Add Tokens and Which Reduce Them

0
·14 views

The Claude Code hooks reference now documents 33 events, though most tutorials show only a handful of simple examples. Some hooks can raise token usage: stdout on UserPromptSubmit, UserPromptExpansion, SessionStart and PostModelSwitch is added to the conversation, and additionalContext stays there after it is inserted. Other hooks can cut tokens, such as updatedInput on PreToolUse, which rewrites a tool call before it runs, and updatedToolOutput on PostToolUse, which replaces a result before Claude reads it. Each injected string is capped at 10,000 characters, and hooks that fire on every tool call cost more than those that fire once per session. Several pitfalls, including exit code 1 not blocking and timed-out PreToolUse hooks letting calls through, can leave a hook silently ineffective.

Read the full story at DEV Community

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

Related stories

0
ProgrammingDEV Community ·

Why Proxies Can't Fully Change a Game's Region Settings

A proxy exit can alter the IP geolocation a publisher sees, but the game client also relies on other signals that a proxy cannot rewrite. Store and account country are set at account creation or by the payment instrument's issuing country, so re-routing does not change them. Matchmaking selects servers by measured round-trip latency, which reflects physical distance rather than the country listed in an IP record. Login history and device data, which feed trust scores, usually worsen when exits are switched. The article suggests comparing the exit's registered country with measured latency to spot tunnelled or resold IP blocks.

0
ProgrammingDEV Community ·

How to use Google's Ads Transparency Center to study competitor ads

Google publishes every Search, YouTube and Display ad in its Ads Transparency Center, along with the dates they ran and the countries where they appeared. The guide explains how to search a competitor's domain, filter by country and ad format, and review each ad's versions and reach. It recommends sorting ads by run length, since long-running ads are likely profitable, and grouping them by landing page to spot which offers convert. The author also presents a paid Apify tool that exports ad data into a spreadsheet, with costs of $1.50 per 1,000 ads, and suggests weekly comparisons to track new tests.

0
ProgrammingDEV Community ·

How to Find Substack Newsletters to Sponsor, Using Real Subscriber Counts

Newsletter sponsorships remain effective because readers tend to pay attention to the ads they see there. Advertisers should look for newsletters that match their customers, are still actively publishing, and fit their budget, with subscriber counts often in the 2,000 to 50,000 range. Manually searching Substack and checking each newsletter's activity and contact details is slow, so the author describes a paid tool that compiles subscriber counts, posting frequency, and author contact links into one table. Before buying, advertisers are advised to read recent issues to confirm writing quality and reader engagement, and to start with a few newsletters while tracking signups per placement. Newsletter owners can also pursue free cross-promotions with peers of similar size.

0
ProgrammingDEV Community ·

SlowPost Holds Angry Drafts Overnight Before Sending Them

SlowPost is an open-source tool that acts as a delayed post office for messages users may regret sending in the moment. Users paste an angry draft, and the system rewrites it into a calmer version using technique cards retrieved and reranked for relevance, with the rewrite scored against a transparent heat lexicon. Letters are held overnight, with production mode unlocking them at 09:00 the next morning and a public demo shortening the hold to three minutes. The project is written in TypeScript with Fastify and zod, stores letters in a small JSON file rather than a database, and lets any OpenAI-compatible endpoint serve the open-weight models. The developer reports that retrieval quality mattered more than prompt wording, and that a smaller, faster model outperformed a newer reasoning model on this narrow task.