Techniques to Reduce Token Consumption in Kiro and Claude Code

Practical techniques to reduce token and credit use in Kiro and Claude Code. Learn to manage context, scope rules, filter output, and match models to tasks.

As teams adopt tools like Kiro and Claude Code, I'm increasingly getting questions about how to use fewer tokens / credits, to save money. I have found that most token consumption comes from context that the model does not need for the task at hand, rather than from the code the agent writes. The good news is that both Kiro and Claude Code provide built-in features to manage that context. This article walks through practical techniques you can apply today, explains how each one works in Kiro and in Claude Code, and ends with a quick reference table and a simple plan for measuring the results.
All product details in this article were checked against the Kiro and Claude Code documentation in November 2026. These tools evolve quickly, so I recommend confirming specific commands and model rates in the references at the end before you roll changes out to a team.

Why token consumption grows during a session

An agentic coding session is a series of requests to a model. With each request, the agent sends the system prompt, your steering or rules files, the definitions of the tools it can use, the conversation so far, and the results of any tool calls made along the way. When the agent reads a file, runs a test, or calls a Model Context Protocol (MCP) tool, that output becomes part of the conversation and is sent again on later requests.
Prompt caching reduces the cost of content that repeats from one request to the next, but it does not remove it. Anthropic's Claude Code documentation notes that a short question in a session that has been open all day still draws usage for the whole conversation, and that a message sent after a long break can miss the cache and reprocess the full context.
Two figures from the documentation help show the scale:
  • Tool definitions add up. The Kiro team found that connecting five MCP servers can load more than 50,000 tokens of tool definitions, about 40% of a context window, before you type your first prompt.
  • Parallel agents multiply usage. Anthropic reports that agent teams use approximately seven times more tokens than a standard Claude Code session when teammates run in plan mode, because each teammate keeps its own context window.
Every technique below works on the same principle: give the model the context it needs for the current task, and keep everything else out.

Technique 1: Keep sessions focused

The simplest way to reduce token consumption is to manage the conversation itself.
Start a fresh session when you switch tasks. Context from an earlier, unrelated task is sent again with every new message. In Claude Code, run  /clear  to start fresh. You can run  /rename  first so you can return to the earlier session later with  /resume . In Kiro, start a new chat session when you move to unrelated work.
Compact long sessions when you need continuity. Compaction summarizes older messages so you can keep working on the same task with a smaller history. Both tools support  /compact . In Claude Code, you can add a focus to guide the summary, for example:
/compact Focus on the API changes and the failing tests
In the Kiro CLI,  /compact  creates a new session with the summarized history. You can return to the original session with  /chat resume . Keep in mind that compaction reads the conversation in order to summarize it, so compacting a very large context is itself a large request. When you do not need the earlier history, starting a new session is the more efficient choice.
Check what is in your context. Both tools show you where your context is going:
  • In the Kiro CLI,  /context show  breaks down the context window into context files, tools, Kiro responses, and your prompts, and shows the percentage each one uses.
  • In Claude Code,  /context  shows what is consuming space, and  /usage  shows token usage for the session, prompt cache statistics, and, on paid plans, a breakdown of recent usage by skill, subagent, plugin, and MCP server, along with recommended changes.
Reviewing this output once or twice a day is a good habit. It quickly shows whether a large rules file, an unused MCP server, or a long session is driving your usage.

Technique 2: Reference files instead of pasting them

When you paste a large block of code or a log file into chat, that text becomes part of the conversation history and is sent with every later request in the session. Referencing the file instead lets the agent read only what it needs, when it needs it.
  • In Kiro chat, type  #  to add specific context such as a file, a folder, terminal output, or a Git diff.
  • In Claude Code, use  @  followed by the file path, for example  @src/auth/login.ts .
Specific references also lead to better answers, because the agent spends less effort searching for the right files.

Technique 3: Scope steering and rules so they load only when relevant

Project instructions are valuable: they keep generated code consistent with your standards. However, instructions that are included in every request add to every request's token count, even when they have nothing to do with the current task. Both Kiro and Claude Code let you load instructions conditionally.

Kiro steering

Kiro steering files live in  .kiro/steering/  in your workspace, or in  ~/.kiro/steering/  for global steering that applies to all workspaces. The  inclusion  setting in each file's front matter controls when the file is loaded:
Inclusion mode
When the file loads
Good fit for
 always  (default)
Every interaction
Core technology stack and coding conventions
 fileMatch 
When files matching  fileMatchPattern  are involved
API, component, test, or infrastructure standards
 manual 
When you reference it with  #  or choose it from the  /  menu
Runbooks, migration guides, troubleshooting steps
 auto 
When your request matches the file's  description 
Detailed domain guidance that is only sometimes relevant
Here is an example of a steering file that loads only when Kiro works with API code:
---
inclusion: fileMatch
fileMatchPattern: ["services/api/**/*.ts", "services/api/**/*.py"]
---
# API standards
- Validate all request bodies with the shared schema module
- Return errors in the standard problem+json format
And here is a file that Kiro includes automatically when your request matches its description:
---
inclusion: auto
name: release-runbook
description: Release and deployment steps. Use when preparing or troubleshooting a release.
---
A few additional points are worth knowing:
  • Kiro also supports  AGENTS.md  files. These are always included and do not support inclusion modes, so keep them short and move detailed guidance into scoped steering files.
  • The foundation steering files  product.md ,  tech.md , and  structure.md  are included in every interaction by default. Keep them focused on the essentials.
  • Custom agents do not load steering files automatically. Add the steering files an agent needs to its  resources  configuration, for example  "resources": ["file://.kiro/steering/**/*.md"] , or use a narrower pattern.

Claude Code rules and CLAUDE.md

Claude Code loads  CLAUDE.md  at the start of every session. Anthropic recommends keeping it under 200 lines and including only essentials. Two features help you do that:
  • Path-scoped rules. Place rules in  .claude/rules/  and add a  paths  list to the front matter. A rule loads only when Claude reads, writes, or edits a matching file.
  • Skills. Move instructions for specific workflows, such as pull request reviews or database migrations, into skills. Skills load only when they are invoked.
---
paths:
- "services/api/**/*.{ts,py}"
---
# API rules
- Validate all request bodies with the shared schema module
Claude Code also includes  /doctor prompt-audit , which reviews your instruction files for outdated, conflicting, or broken instructions and proposes edits.

Technique 4: Exclude files the agent does not need

Build output, dependency folders, lock files, and binary assets rarely help an agent write code, but they can easily end up in search results and file reads. Excluding them keeps context focused and also keeps sensitive files out of reach.

Kiro: .kiroignore

Create a  .kiroignore  file in your project root, or in any subdirectory, using the same syntax as  .gitignore . You can also create a global ignore file at  ~/.kiro/settings/kiroignore . Kiro blocks matching files from direct reads and filters them out of file and content search results.
In the Kiro IDE, add  .kiroignore  to the Agent Ignore Files setting ( kiroAgent.agentIgnoreFiles ). This setting accepts a list of file names, so you can use  .gitignore  and  .kiroignore  together. In the Kiro CLI,  .kiroignore  is supported in V3.
# Dependencies and build output
node_modules/
.venv/
dist/
build/
coverage/

# Large files with little value to the agent
*.lock
package-lock.json

# Secrets
.env
.env.*
!.env.example
*.pem
*.key

Claude Code: permission deny rules

Claude Code uses  Read  deny rules in  .claude/settings.json  (for a project) or  ~/.claude/settings.json  (for a user). You may see a  .claudeignore  file recommended online, but Claude Code does not read that file, so use deny rules instead:
{
"permissions": {
"deny": [
"Read(./node_modules/**)",
"Read(./dist/**)",
"Read(./build/**)",
"Read(./coverage/**)",
"Read(./**/*.lock)",
"Read(./.env*)"
]
}
}
If your code base handles regulated or sensitive data, such as sample data sets, images, or exported records, add those paths to your exclusions as well. It keeps that data out of the agent's context and reduces token consumption at the same time.

Technique 5: Reduce MCP tool overhead

MCP servers give agents access to databases, design tools, observability platforms, and many other services. Each connected server also brings tool definitions that describe what the agent can call.
In Kiro, use Kiro powers. A power packages an MCP server together with a  POWER.md  steering file and optional hooks. Instead of loading every tool definition up front, Kiro activates a power when your request is relevant to it. For example, a database power activates when you mention database work and deactivates when you move on to something else. With powers, your baseline MCP context stays close to zero until a power is needed. Powers are available in the Kiro IDE, where you can install curated powers from partners, community-built powers, or your own team's powers.
In Claude Code, review which servers are connected. Claude Code loads only tool names and server instructions into context until a specific tool is used. Run  /context  to see what is consuming space, and use  /mcp  to disable servers you are not using. Where a command-line tool is available, such as the AWS CLI or the GitHub CLI, the agent can often run it directly, which adds no tool definitions to context.
For typed languages, Claude Code also supports code intelligence plugins that give the agent precise symbol navigation. A single "go to definition" lookup can replace a text search followed by reading several candidate files.

Technique 6: Filter command and log output before it reaches the model

Test runners, build tools, and verbose logs can produce thousands of lines of output. If the agent runs these commands directly, all of that output becomes part of the conversation. Hooks let you trim the output before the model sees it.
In Claude Code, a  PreToolUse  hook can rewrite a command before it runs. The following configuration calls a script whenever Claude runs a shell command:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "command": "~/.claude/hooks/filter-test-output.sh" }
]
}
]
}
}
This script keeps only the last 100 lines of output from common test runners and leaves other commands unchanged:
#!/bin/bash
# Keep only the last 100 lines of output from common test runners
input=$(cat)
cmd=$(echo "$input" | jq -r '.tool_input.command')

if [[ "$cmd" =~ ^(npm\ test|pytest|go\ test) ]]; then
echo "$input" | jq --arg c "$cmd 2>&1 | tail -n 100" \
'{hookSpecificOutput: {hookEventName: "PreToolUse", updatedInput: (.tool_input + {command: $c})}}'
else
echo "{}"
fi
Save the script to  ~/.claude/hooks/filter-test-output.sh , make it executable with  chmod +x , and run  /hooks  to confirm it is registered. Anthropic's cost documentation includes a stricter version of this pattern that you can adapt for your team. You can apply the same idea to filter logs for lines that contain  ERROR  or  FAIL .
Kiro supports agent hooks as well. For a lighter-weight approach, you can add a short steering rule that asks the agent to pipe long test and build output through  tail  or  grep  before reading it.

Technique 7: Delegate verbose work to subagents

Some tasks produce a lot of output but only a short useful answer, for example running a test suite, searching through logs, or reading documentation. Delegating these tasks to a subagent keeps the verbose output in the subagent's own context. Only the summary returns to your main session.
Subagent requests still count toward your usage, so match the model to the job. In Claude Code, you can set  model: haiku  in a subagent's definition for simple, well-defined tasks.

Technique 8: Match the model to the task

Not every request needs the most capable model. Choosing the model per task is one of the most direct ways to manage credit consumption.

Kiro

Kiro's Auto mode routes each request to a suitable model using a mix of frontier models, specialized models, and optimizations such as intent detection and caching. Auto is the baseline for Kiro credit pricing at 1x, and it is a good default for most work. The Kiro team has continued to improve Auto's efficiency; after one update, Kiro reported that typical requests used 21% fewer credits, and the most complex requests used 36% fewer.
When you want to choose a model yourself, the Kiro model picker shows the credit multiplier for each model relative to Auto. The following values are from the Kiro model picker and documentation in November 2026:
Model
Credits relative to Auto
Context window
Claude Haiku 5.5
0.06x
1M
GPT 5.6 Luna
0.6x
1M
Auto
1x
Not applicable
Claude Sonnet 5.5
1.3x
1M
Claude Opus 5.5
2x
1M
GPT 5.6 Terra
2.2x
1M
Grok 4.7 (experimental preview)
2.7x
500K
GPT 5.6 Sol
4.4x
1M
Some models use two-tier pricing based on request size. For example, Claude Haiku 5.5 is billed at 0.06x for requests up to 100K tokens and 0.3x above that, and GPT 5.6 models are billed at double their listed rate above 272K tokens. This is another reason to keep sessions focused: a long session can push requests over these thresholds.
A practical approach is to use Auto by default, use a lower-multiplier model such as Claude Haiku 5.5 for routine edits and boilerplate, and reserve higher-multiplier models for complex design work. Kiro's documentation also notes that models with the same multiplier can use different amounts of credit for the same task, depending on output length, reasoning depth, and tokenizer, so measure on your own work.

Claude Code

Anthropic recommends Sonnet for most coding tasks and Opus for complex architectural decisions or multi-step reasoning. You can switch models during a session with  /model  or set a default in  /config . Claude Code can also use Amazon Bedrock for inference, which lets teams use their AWS accounts and existing governance controls.
Extended thinking improves results on complex problems, but thinking tokens are billed as output tokens. For straightforward tasks, lower the effort level with  /effort . On models with a fixed thinking budget, you can set the  MAX_THINKING_TOKENS  environment variable, for example  MAX_THINKING_TOKENS=8000 . Models that use adaptive reasoning ignore this setting, so use effort levels with those models instead.

Technique 9: Plan before you build

Vague requests lead agents to explore broadly, and a wrong first approach leads to expensive rework. A few habits help the agent get it right the first time:
  • Plan first. For larger changes, start with a Kiro spec, which captures requirements, design, and tasks before any code is written. In Claude Code, press Shift+Tab to switch to plan mode so Claude proposes an approach for your approval before making changes.
  • Be specific. A request such as "add input validation to the login function in auth.ts" requires far less exploration than "improve this code base."
  • Give the agent a way to check its work. Include test cases or expected output in your request so the agent can verify its changes before you review them.
  • Correct course early. If the agent heads in the wrong direction, stop it right away. In Claude Code, press Esc to stop and use  /rewind  to return to an earlier checkpoint.
  • Batch related changes. One well-scoped request is usually more efficient than a series of small follow-up corrections.

Technique 10: Evaluate community token reduction tools

Several open-source projects aim to reduce token consumption further. These are community projects, not AWS or Anthropic products, and the savings figures below are reported by the projects themselves. I recommend testing them on a non-production repository first and reviewing them with your security team before using them with sensitive code.

KiroGraph

 KiroGraph  builds a local knowledge graph of your code base and makes it available to Kiro as an MCP server. It parses source code with tree-sitter and supports more than 30 languages, as well as infrastructure definitions such as Terraform, Helm, and Kubernetes. Instead of running many searches and reading many files, Kiro can ask the graph for callers, call graphs, type hierarchies, and the impact of a change in a single tool call.
In my experience, KiroGraph reduces token consumption on large blast-radius questions, such as understanding an unfamiliar code base, assessing the impact of changing a shared function, re-architecting a module, or finding the tests affected by a change. For small, localized edits, where the agent already knows the one or two files involved, the graph adds tool calls without much benefit. Use it for the first kind of work and let the agent work directly for the second. Full support is for Kiro, and the project offers experimental integrations for other MCP-compatible tools.

Caveman

 Caveman  is a skill and plugin that asks the agent to respond in concise prose while keeping code, commands, and error messages exact. It works with Claude Code, Kiro, and other agents. The project reports approximately 65 to 75% fewer output tokens. Because most tokens in an agentic session are input tokens, such as history, files, and tool results, the overall reduction is smaller than the output figure. Caveman is most useful in long sessions where the agent's explanations make up a meaningful share of the output.

RTK

 RTK  is a command-line proxy that filters and compresses output from common development commands, such as Git, test runners, and build tools, before it reaches the model. It installs as a hook and applies the same idea as the hook in Technique 6 across a broader set of commands. The project reports 60 to 90% savings on common development commands.

A simple evaluation approach

  1. Record a baseline on two representative tasks: one large change that spans several modules, and one small edit.
  1. Install the tool in a non-production workspace and repeat both tasks.
  1. Compare credits or tokens, the number of tool calls, and the quality of the result.
  1. Review the tool's source code, permissions, and network access, especially for hooks and proxies that see command output.
  1. Approve the tool for the use cases where it helps, rather than as a default for all work.

Measure the results

Changes are easier to sustain when you can see their effect. Establish a baseline before you make changes, and compare against it each week.
  • Amazon CloudWatch Coding Agent Insights. Claude Code emits OpenTelemetry metrics for token usage, sessions, code edits, tool calls, and cost. When you send these metrics to Amazon CloudWatch, they populate the Coding Agent Insights dashboards, which give you a team-wide view of how coding agents are used. The CloudWatch documentation covers setup options for individual developers and for organizations that use single sign-on.
  • Claude Code  /usage . Shows session-level usage and, on paid plans, attribution and recommendations over the last day or week.
  • Kiro CLI  /context show . Shows how the context window is divided between files, tools, responses, and prompts. Track credit consumption for your Kiro subscription over the same period.

Quick reference

Technique
Kiro
Claude Code
Start fresh or compact
New session;  /compact  in the CLI
 /clear ;  /compact  with a focus
Inspect context
 /context show  in the CLI
 /context ;  /usage 
Reference files
 #  context in chat
 @path/to/file 
Conditional instructions
Steering with  fileMatch ,  manual , or  auto  inclusion
 .claude/rules/  with  paths ; skills
Always-on instructions
Keep  AGENTS.md  and foundation steering files short
Keep  CLAUDE.md  under 200 lines
File exclusions
 .kiroignore  plus the Agent Ignore Files setting
 permissions.deny   Read  rules
MCP overhead
Kiro powers
Review with  /context ; disable idle servers with  /mcp 
Output filtering
Agent hooks; concise steering rules
 PreToolUse  hooks
Verbose tasks
Subagents
Subagents with a lighter model
Model and effort
Auto by default; lower-multiplier models for routine work
 /model ;  /effort ;  MAX_THINKING_TOKENS 
Plan first
Specs
Plan mode (Shift+Tab)
Measure
 /context show ; subscription credit usage
 /usage ; CloudWatch Coding Agent Insights

Conclusion

Most of the token savings available in Kiro and Claude Code come from a handful of habits: keep sessions focused, load instructions only when they are relevant, keep unneeded files and verbose output out of context, and choose the model that fits the task. These techniques use features that are already built into both tools, so you can start applying them today. Begin with session hygiene and file exclusions, which take minutes to adopt, then scope your steering and rules, and measure the results so you can see what works best for your team.

References

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article