The /knowledge command provides persistent knowledge base functionality for Kiro CLI, allowing you to store, search, and manage contextual information that persists across chat sessions.
Knowledge management is experimental and must be enabled before use:
kiro-cli settings chat.enableKnowledge true
Once enabled, use /knowledge commands within your chat session:
/knowledge add --name myproject --path /path/to/project /knowledge show
Display all entries in your knowledge base with detailed information including creation dates, item counts, and persistence status. Also shows any active background indexing operations with progress and ETA.
This unified command provides a complete view of both your stored knowledge and ongoing operations.
/knowledge show
Add files or directories to your knowledge base. The system recursively indexes all supported files in directories.
Syntax:
/knowledge add --name <name> --path <path> [--include pattern] [--exclude pattern] [--index-type Fast|Best]
Required Parameters:
--name or -n: Descriptive name for the knowledge entry--path or -p: Path to file or directory to indexExamples:
/knowledge add --name "project-docs" --path /path/to/documentation /knowledge add -n "config-files" -p /path/to/config.json /knowledge add --name "fast-search" --path /path/to/logs --index-type Fast /knowledge add -n "semantic-search" -p /path/to/docs --index-type Best
Choose the indexing approach that best fits your needs:
Advantages:
Disadvantages:
Advantages:
Disadvantages:
| Use Case | Recommended Type | Why |
|---|---|---|
| Log files, error messages | Fast | Quick keyword searches, large volumes |
| Configuration files | Fast | Exact parameter/value lookups |
| Large codebases | Fast | Fast symbol and function searches |
| Documentation | Best | Natural language understanding |
| Research papers | Best | Concept-based searching |
| Mixed content | Best | Better overall search experience |
If you don't specify --index-type, the system uses your configured default:
# Set your preferred default kiro-cli settings knowledge.indexType Fast # or Best # This will use your default setting /knowledge add "my-project" /path/to/project
Control which files are indexed using include and exclude patterns:
/knowledge add "rust-code" /path/to/project --include "*.rs" --exclude "target/**" /knowledge add "docs" /path/to/project --include "**/*.md" --include "**/*.txt" --exclude "node_modules/**"
Pattern Examples:
*.rs - All Rust files recursively (equivalent to **/*.rs)**/*.py - All Python files recursivelytarget/** - Everything in target directorynode_modules/** - Everything in node_modulesDefault Pattern Behavior:
When you don't specify patterns, the system uses configured defaults:
kiro-cli settings knowledge.defaultIncludePatterns '["**/*.rs", "**/*.py"]' kiro-cli settings knowledge.defaultExcludePatterns '["target/**", "__pycache__/**"]' # Uses default patterns /knowledge add "my-project" /path/to/project # Overrides defaults /knowledge add "docs-only" /path/to/project --include "**/*.md"
Text files: .txt, .log, .rtf, .tex, .rst
Markdown: .md, .markdown, .mdx
JSON: .json (treated as text for searchability)
Configuration: .ini, .conf, .cfg, .properties, .env
Data files: .csv, .tsv
Web formats: .svg (text-based)
Code files: .rs, .py, .js, .jsx, .ts, .tsx, .java, .c, .cpp, .h, .hpp, .go, .rb, .php, .swift, .kt, .kts, .cs, .sh, .bash, .zsh, .html, .htm, .xml, .css, .scss, .sass, .less, .sql, .yaml, .yml, .toml
Special files: Dockerfile, Makefile, LICENSE, CHANGELOG, README (files without extensions)
Note: Unsupported files are indexed without text content extraction.
Remove entries from your knowledge base by name, path, or context ID.
/knowledge remove "project-docs" # Remove by name /knowledge remove /path/to/old/project # Remove by path
Update an existing knowledge base entry with new content. Original include/exclude patterns are preserved.
/knowledge update /path/to/updated/project
Remove all entries from your knowledge base. Requires confirmation and cannot be undone.
/knowledge clear
You'll be prompted:
⚠️ This will remove ALL knowledge base entries. Are you sure? (y/N):
Cancel background operations. Cancel specific operation by ID or all operations.
/knowledge cancel abc12345 # Cancel specific operation /knowledge cancel all # Cancel all operations
Configure knowledge base behavior:
# Maximum files per knowledge base kiro-cli settings knowledge.maxFiles 10000 # Text chunk size for processing kiro-cli settings knowledge.chunkSize 1024 # Overlap between chunks kiro-cli settings knowledge.chunkOverlap 256 # Default index type kiro-cli settings knowledge.indexType Fast # Default include patterns kiro-cli settings knowledge.defaultIncludePatterns '["**/*.rs", "**/*.md"]' # Default exclude patterns kiro-cli settings knowledge.defaultExcludePatterns '["target/**", "node_modules/**"]'
Each agent maintains its own isolated knowledge base, ensuring knowledge contexts are scoped to the specific agent you're working with. This provides better organization and prevents knowledge conflicts.
Knowledge bases are stored in:
~/.kiro/knowledge_bases/ ├── kiro_cli_default/ # Default agent │ ├── contexts.json │ ├── context-id-1/ │ │ ├── data.json │ │ └── bm25_data.json │ └── context-id-2/ │ └── data.json ├── my-custom-agent_<code>/ # Custom agent │ ├── contexts.json │ └── context-id-3/ │ └── data.json └── another-agent_<code>/ # Another agent ├── contexts.json └── context-id-4/ └── data.json
/knowledge commands operate on current agent's knowledge baseWhen you switch agents, knowledge commands automatically work with that agent's knowledge base:
# Working with default agent /knowledge add /path/to/docs # Switch to custom agent kiro chat --agent my-custom-agent # Creates separate knowledge base for my-custom-agent /knowledge add /path/to/agent/docs # Switch back to default kiro chat # Only sees original docs, not agent-specific docs /knowledge show
Knowledge bases use semantic search:
--exclude "target/**" --exclude "node_modules/**"/knowledge show to monitor indexing progresstarget/**, node_modules/**, .git/**/knowledge show to check indexing status/knowledge show to ensure completion/knowledge show/knowledge show for progress/knowledge cancel for problematic operationsmaxFiles or chunkSize for better performance** for recursive)
Knowledge management