Kiro offers three ways to provide context, each optimized for different use cases:
| Approach | Context Window Impact | Persistence | Best For |
|---|---|---|---|
| Agent Resources | Always active (consumes tokens) | Persistent across sessions | Essential project files, standards, configs |
| Session Context | Always active (consumes tokens) | Current session only | Temporary files, quick experiments |
| Knowledge Bases | Only when searched | Persistent across sessions | Large codebases, extensive documentation |
Use this decision tree to choose the appropriate context approach:
Do you need this context in every conversation?
> /context show Agent - .kiro/steering/**/*.md <project-root>/.kiro/steering/product.md <project-root>/.kiro/steering/structure.md <project-root>/.kiro/steering/tech.md <project-root>/.kiro/steering/testing.md - README.md <project-root>/snake/README.md - ~/.kiro/steering/**/*.md (no matches) Session (temporary) <none> 5 matched files in use - <project-root>/.kiro/steering/testing.md (0.1% of context window) - <project-root>/snake/.kiro/steering/tech.md (0.1% of context window) - <project-root>/snake/README.md (0.1% of context window) - <project-root>/snake/.kiro/steering/structure.md (0.2% of context window) - <project-root>/snake/.kiro/steering/product.md (0.1% of context window) Context files total: 0.5% of context window
The output shows:
Context files are limited to 75% of your model's context window. Files exceeding this limit are automatically dropped.
Knowledge bases don't consume context window space until searched, making them ideal for large reference materials. For more information, see Knowledge base context (for large datasets).
Context files contain information you want Kiro to consider during your conversations. These can include project requirements, coding standards, development rules, or any other information that helps Kiro provide more relevant responses.
The recommended way to configure context is through the resources field in your agent configuration file. This creates persistent context that is available every time you use the agent.
Add file paths or glob patterns to the resources array in your agent config:
{ "name": "my-agent", "description": "My development agent", "resources": [ "file://README.md", "file://docs/**/*.md", "file://src/config.py" ] }
Resources must be prefixed with file:// to be included as context files. These files will be automatically available in all chat sessions using this agent.
You can temporarily add files to your current chat session using the /context add command. These additions are only available for the current session and will not persist when you start a new chat session.
> /context add README.md Added 1 path(s) to context.
Note: Context modifications via slash command is temporary.
You can also add multiple files at once using glob patterns:
> /context add docs/*.md Added 3 path(s) to context.
To make context changes permanent, add the files to your agent's resources field instead. For more information, see Configuring persistent context with agent resources.
For large codebases, documentation sets, or reference materials that would exceed context window limits, use knowledge bases. Knowledge bases provide semantic search capabilities without consuming context window space until searched.
Enable knowledge bases:
kiro-cli settings chat.enableKnowledge true
Add content to a knowledge base:
kiro-cli chat
/knowledge add /path/to/large-codebase --include "/*.py" --exclude "node_modules/"
Knowledge bases are searched on-demand by Kiro when relevant information is needed, making them ideal for large reference materials.
To view your current context, use the /context show command:
> /context show Current context window (5.9% used) |||████████████████████████████████████████████████████████████████ 5.9% █ Context files 0.9% █ Tools 0.5% █ Kiro responses 0.7% █ Your prompts 3.8%
To remove files from your current session context:
> /context remove src/temp-file.py Removed 1 path(s) from context.
To clear all session context, use the /context clear command:
> /context clear Cleared context Note: Context modifications via slash command is temporary.
Note: You cannot remove agent-defined context using /context commands. To permanently remove context, edit your agent's resources field.
Here are some common reasons for actively managing your context window:
/context add commands, consider moving them to your agent's resources field for persistence:# Instead of running these commands every session: > /context add README.md > /context add docs/*.md # Add them to your agent config once: { "resources": [ "file://README.md", "file://docs/**/*.md" ] }
You can configure a default agent that includes your preferred context files. This ensures your context is automatically available in new chat sessions without needing to specify the agent each time.
>kiro-cli settings chat.defaultAgent my-project-agent
# This would consume too many tokens: > /context add src/**/*.py # Use knowledge base instead: > /knowledge add src/ --include "**/*.py" --exclude "__pycache__/**"
.gitignore to prevent accidental commits of sensitive context
Context management