{"slug": "ai-coding-is-getting-expensive-how-developers-can-stop-burning-tokens", "title": "AI Coding Is Getting Expensive: How Developers Can Stop Burning Tokens", "summary": "A developer explains that AI coding agents consume far more tokens than users realize because they process repository context, conversation history, tool output, and test logs beyond the initial prompt. The post offers practical tips to reduce token usage, such as narrowing context, splitting sessions by task, trimming logs, and choosing models appropriately.", "body_md": "AI coding tools are getting ridiculously good.\n\nYou can open a project, describe a feature, and let an agent inspect files, modify code, run tests, debug failures, and sometimes work for a long time without you touching the keyboard.\n\nThat feels amazing.\n\nUntil you look at your usage.\n\nSuddenly one small feature has consumed a huge amount of tokens.\n\nAnd the strange part is that you may have only written a few sentences.\n\nSo where did all those tokens go?\n\nThe answer is simple:\n\n**Your prompt is only a tiny part of what an AI coding agent actually processes.**\n\nImagine you type:\n\n```\nFix the authentication bug.\n```\n\nThat looks like five tokens worth of work.\n\nBut the agent may then:\n\nEvery one of those steps may add more context.\n\nOpenAI's own documentation says that larger codebases, longer-running tasks, and sessions that require more context consume substantially more usage than simple scripts or functions.\n\nSo the real equation is closer to:\n\n```\nYour prompt\n+ repository context\n+ conversation history\n+ tool output\n+ generated code\n+ test logs\n+ repeated agent iterations\n= token usage\n```\n\nAnd that can become very large very quickly.\n\nOne of the easiest ways to waste tokens is giving the agent too much context.\n\nInstead of:\n\n```\nReview my project and fix the checkout issue.\n```\n\nTry:\n\n```\nThe bug is in the checkout flow.\n\nStart with:\nsrc/features/checkout/\nsrc/api/payments.ts\n\nDo not inspect unrelated folders unless necessary.\n```\n\nYou are giving the agent a boundary.\n\nThis is especially important in large monorepos.\n\nIf your project contains:\n\n```\nfrontend/\nbackend/\nmobile/\ninfrastructure/\ndocs/\nscripts/\nlegacy/\n```\n\nthe agent usually doesn't need everything just to fix one button.\n\n**More context does not automatically mean a better answer.**\n\nRelevant context is what matters.\n\nDevelopers often keep one AI conversation alive for hours.\n\nFor example:\n\n```\nBuild login\n↓\nFix dashboard\n↓\nCreate payments\n↓\nDebug deployment\n↓\nOptimize database\n```\n\nThe problem is that the agent may keep carrying information from earlier work.\n\nYour deployment problem probably doesn't need all the context from the login implementation.\n\nA better workflow is:\n\n```\nSession 1 → Authentication\n\nSession 2 → Payments\n\nSession 3 → Deployment\n```\n\nTreat AI conversations like branches.\n\nWhen the problem changes significantly, create a clean context.\n\nThis is one of the biggest token traps.\n\nDevelopers regularly paste thousands of lines like:\n\n```\nnpm run build\n\n[5000 lines of output]\n```\n\nBut somewhere near the bottom the useful information is simply:\n\n```\nTypeError: Cannot read properties of undefined\n\nsrc/auth/session.ts:82\n```\n\nGive the AI the useful part first.\n\n```\nBuild fails with:\n\nTypeError: Cannot read properties of undefined\nsrc/auth/session.ts:82\n\nHere is the surrounding function:\n...\n```\n\nIf the agent actually needs the full log, it can ask for it or inspect it through tools.\n\nDon't make thousands of irrelevant lines part of the context by default.\n\nNot every coding task needs your most powerful model.\n\nYou probably don't need maximum reasoning to:\n\nReserve expensive models for tasks such as:\n\nA useful mental model is:\n\n```\nSimple task → fast/cheap model\n\nComplex task → stronger model\n```\n\nUsing the biggest model for every tiny task is like hiring a senior architect to rename CSS classes.\n\nBad prompt:\n\n```\nImprove this API.\n```\n\nWhat does \"improve\" mean?\n\nThe agent may explore architecture, performance, naming, security, validation, documentation and testing.\n\nThat means more exploration.\n\nMore exploration means more tokens.\n\nInstead:\n\n```\nOptimize this endpoint only for database query count.\n\nGoal:\nReduce the current 8 queries to 3 or fewer.\n\nDo not change the API response format.\n\nRun the existing tests when finished.\n```\n\nNow the search space is much smaller.\n\nThe AI knows exactly when it should stop.\n\nFiles such as:\n\n```\nAGENTS.md\nCLAUDE.md\n.cursor/rules/\n```\n\ncan be extremely useful.\n\nBut developers sometimes turn them into huge documentation dumps.\n\nRemember that persistent instructions can become part of your agent's context repeatedly.\n\nCursor, for example, explains that applicable rules are included in model context to give the agent persistent guidance.\n\nInstead of writing 5,000 lines of instructions, keep the important rules concise.\n\n```\nStack:\nNext.js + TypeScript + PostgreSQL\n\nRules:\n- Use server components by default\n- Use Zod for validation\n- Never access DB directly from UI components\n- Run npm test before completion\n- Do not modify migrations without approval\n```\n\nThat's usually far more useful than an enormous internal handbook.\n\nThis pattern can get expensive:\n\n```\nAgent writes code\n↓\nTest fails\n↓\nAgent changes code\n↓\nTest fails\n↓\nAgent changes code\n↓\nTest fails\n↓\n...\n```\n\nAfter a few failures, stop the loop.\n\nAsk:\n\n```\nStop editing.\n\nExplain why the last three attempts failed.\n\nIdentify the root cause before making another change.\n```\n\nThis forces the agent back into diagnosis instead of continuing random trial-and-error.\n\nSometimes you only want to understand a problem.\n\nDon't immediately tell the AI:\n\n```\nFix it.\nDo not modify anything yet.\n\nInspect the relevant files and explain:\n1. the likely cause\n2. which files need changes\n3. the smallest possible fix\n```\n\nThen approve the implementation.\n\nOpenAI actually recommends beginning some Codex workflows in an \"Ask\" style before moving into implementation, particularly when understanding the codebase or problem first is useful.\n\nThis can prevent the agent from performing an expensive exploration-and-edit loop you never needed.\n\nThere is another optimization most developers never think about: **prompt caching**.\n\nOpenAI explains that caching works best when repeated, static instructions remain at the beginning of a prompt while changing information is placed later.\n\nConceptually, prefer:\n\n```\nProject rules\nArchitecture rules\nCoding conventions\n\nTask-specific request\nCurrent error\nCurrent file\n```\n\nrather than constantly rewriting your core instructions.\n\nReusable, stable context is easier for systems to optimize than completely different giant prompts every time.\n\n```\nBuild the feature.\n```\n\nI try to give AI something closer to:\n\n```\nTask:\nAdd password reset.\n\nScope:\nsrc/features/auth/\nsrc/api/auth/\n\nRequirements:\n- Email reset link\n- Token expires after 30 minutes\n- Existing login behavior must not change\n\nFirst:\nInspect the relevant files and propose the smallest implementation.\n\nThen:\nImplement it.\n\nFinally:\nRun the related tests.\n\nDo not inspect unrelated folders unless required.\n```\n\nThis doesn't just save tokens.\n\nIt usually produces better engineering work.\n\nThis is the important part.\n\nThe goal shouldn't be:\n\nUse as few tokens as possible.\n\nIf an AI agent consumes $5 of compute but saves you three hours of engineering work, that may be an excellent trade.\n\nThe real goal is:\n\n**Don't spend tokens on context and work that doesn't improve the result.**\n\nAgentic coding is moving toward longer, more autonomous tasks. OpenAI reported in 2026 that more than 70% of sampled Codex users had asked it to perform at least one task estimated to exceed an hour of human work, and some heavy users were running many agent tasks in parallel.\n\nThat means token efficiency is slowly becoming another engineering skill.\n\nJust like we learned to think about:\n\n```\nCPU\nMemory\nDatabase queries\nCloud costs\nAPI requests\n```\n\ndevelopers now also need to think about:\n\n```\nContext\nTokens\nAgent loops\nModel choice\nTool calls\n```\n\nThe best AI developer won't necessarily be the person who uses AI the most.\n\nIt may be the developer who knows **exactly how much AI is actually needed to solve the problem.**\n\nHow are you managing token usage in Cursor, Claude Code, Codex, or other coding agents?\n\nI'd be interested to hear what has worked for you.", "url": "https://wpnews.pro/news/ai-coding-is-getting-expensive-how-developers-can-stop-burning-tokens", "canonical_source": "https://dev.to/robertadam987_/ai-coding-is-getting-expensive-how-developers-can-stop-burning-tokens-491g", "published_at": "2026-09-08 10:07:27+00:00", "updated_at": "2026-09-08 10:33:00.712340+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "large-language-models"], "entities": ["OpenAI"], "alternates": {"html": "https://wpnews.pro/news/ai-coding-is-getting-expensive-how-developers-can-stop-burning-tokens", "markdown": "https://wpnews.pro/news/ai-coding-is-getting-expensive-how-developers-can-stop-burning-tokens.md", "text": "https://wpnews.pro/news/ai-coding-is-getting-expensive-how-developers-can-stop-burning-tokens.txt", "jsonld": "https://wpnews.pro/news/ai-coding-is-getting-expensive-how-developers-can-stop-burning-tokens.jsonld"}}