kimi-cli
AGENTS.md11k starsChanged 41 days agoApache-2.0Archived repositoryView on GitHub
If running tools directly, use uv run .... Kimi Code CLI is a Python CLI agent for software engineering workflows. It supports an interactive shell UI, ACP server mode for IDE integrations, and MCP tool loading. - CLI entry: src/kimicli/cli/init.py (Typer) parses flags (UI mode, agent spec, config, MCP) and routes into KimiCLI in src/kimicli/app.py. - App/runtime setup: KimiCLI.create loads config (src/kimicli/config.py), chooses a model/provider (src/kimicli/llm.py), builds a Runtime (src/kimi_cli/soul/agent.py), loads an agent spec, restores Context, then constructs KimiSoul. -…
- Commits and pushes
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
If running tools directly, use uv run ....
- Distinctive: line 137
Ensure main is up to date (pull latest).
- Very specific: line 138
Create a release branch, e.g.
- Very specific: line 139
Update CHANGELOG.md: add a new ## 0.68 (YYYY-MM-DD) section below ## Unreleased (do not rename ## Unreleased).
- Very specific: line 141
Run uv sync to align uv.lock.
- Distinctive: line 142
Commit the branch and open a PR.
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Kimi Code CLI
Quick commands (use uv)
make prepare(sync deps for all workspace packages and install git hooks)make formatmake checkmake testmake ai-testmake build/make build-bin
If running tools directly, use uv run ....
Project overview
Kimi Code CLI is a Python CLI agent for software engineering workflows. It supports an interactive shell UI, ACP server mode for IDE integrations, and MCP tool loading.
Tech stack
- Python 3.12+ (tooling configured for 3.14)
- CLI framework: Typer
- Async runtime: asyncio
- LLM framework: kosong
- MCP integration: fastmcp
- Logging: loguru
- Package management/build: uv + uv_build; PyInstaller for binaries
- Tests: pytest + pytest-asyncio; lint/format: ruff; types: pyright + ty
Architecture overview
- CLI entry:
src/kimi_cli/cli/__init__.py(Typer) parses flags (UI mode, agent spec, config, MCP) and routes intoKimiCLIinsrc/kimi_cli/app.py. - App/runtime setup:
KimiCLI.createloads config (src/kimi_cli/config.py), chooses a model/provider (src/kimi_cli/llm.py), builds aRuntime(src/kimi_cli/soul/agent.py), loads an agent spec, restoresContext, then constructsKimiSoul. - Agent specs: YAML under
src/kimi_cli/agents/loaded bysrc/kimi_cli/agentspec.py. Specs canextendbase agents, select tools by import path, and register builtin subagent types via thesubagentsfield. Subagent instances are persisted separately under the session directory and can be resumed byagent_id. System prompts live alongside specs; builtin args includeKIMI_NOW,KIMI_WORK_DIR,KIMI_WORK_DIR_LS,KIMI_AGENTS_MD,KIMI_SKILLS,KIMI_OS,KIMI_SHELL(this file is injected viaKIMI_AGENTS_MD). - Tooling:
src/kimi_cli/soul/toolset.pyloads tools by import path, injects dependencies, and runs tool calls. Built-in tools live insrc/kimi_cli/tools/(agent, shell, file, web, todo, background, dmail, think, plan). MCP tools are loaded viafastmcp; CLI management is insrc/kimi_cli/mcp.pyand stored in the share dir. - Subagents:
LaborMarketinsrc/kimi_cli/soul/agent.pyregisters builtin subagent types. TheAgenttool (src/kimi_cli/tools/agent/) creates or resumes subagent instances, whileSubagentStorepersists instance metadata, prompts, wire logs, and context undersession/subagents/<agent_id>/. - Core loop:
src/kimi_cli/soul/kimisoul.pyis the main agent loop. It accepts user input, handles slash commands (src/kimi_cli/soul/slash.py), appends toContext(src/kimi_cli/soul/context.py), calls the LLM (kosong), runs tools, and performs compaction (src/kimi_cli/soul/compaction.py) when needed. - Approvals:
src/kimi_cli/soul/approval.pyis the tool-facing facade.ApprovalRuntimeinsrc/kimi_cli/approval_runtime/is the session-level source of truth for pending approvals, and approval requests are projected onto the root wire stream for Shell/Web style UIs. - UI/Wire:
src/kimi_cli/soul/run_soulconnectsKimiSoulto aWire(src/kimi_cli/wire/) so UI loops can stream events. UIs live insrc/kimi_cli/ui/(shell/print/acp/wire). - Shell UI:
src/kimi_cli/ui/shell/handles interactive TUI input, shell command mode, and slash command autocomplete; it is the default interactive experience. - Slash commands: Soul-level commands live in
src/kimi_cli/soul/slash.py; shell-level commands live insrc/kimi_cli/ui/shell/slash.py. The shell UI exposes both and dispatches based on the registry. Standard skills register/skill:<skill-name>and loadSKILL.mdas a user prompt; flow skills register/flow:<skill-name>and execute the embedded flow.
Major modules and interfaces
src/kimi_cli/app.py:KimiCLI.create(...)andKimiCLI.run(...)are the main programmatic entrypoints; this is what UI layers use.src/kimi_cli/soul/agent.py:Runtime(config, session, builtins),Agent(system prompt + toolset), andLaborMarket(builtin subagent type registry).src/kimi_cli/soul/kimisoul.py:KimiSoul.run(...)is the loop boundary; it emits Wire messages and executes tools viaKimiToolset.src/kimi_cli/soul/context.py: conversation history + checkpoints; used by DMail for checkpointed replies.src/kimi_cli/soul/toolset.py: load tools, run tool calls, bridge to MCP tools.src/kimi_cli/ui/*: shell/print/acp frontends; they consumeWiremessages.src/kimi_cli/wire/*: event types and transport used between soul and UI.
Repo map
src/kimi_cli/agents/: built-in agent YAML specs and promptssrc/kimi_cli/prompts/: shared prompt templatessrc/kimi_cli/soul/: core runtime/loop, context, compaction, approvalssrc/kimi_cli/tools/: built-in toolssrc/kimi_cli/ui/: UI frontends (shell/print/acp/wire)src/kimi_cli/acp/: ACP server componentspackages/kosong/,packages/kaos/: workspace deps- Kosong is an LLM abstraction layer designed for modern AI agent applications. It unifies message structures, asynchronous tool orchestration, and pluggable chat providers so you can build agents with ease and avoid vendor lock-in.
- PyKAOS is a lightweight Python library providing an abstraction layer for agents to interact with operating systems. File operations and command executions via KAOS can be easily switched between local environment and remote systems over SSH.
tests/,tests_ai/: test suitesklips: Kimi Code CLI Improvement Proposals
Conventions and quality
- Python >=3.12 (ty config uses 3.14); line length 100.
- Ruff handles lint + format (rules: E, F, UP, B, SIM, I); pyright + ty for type checks.
- Tests use pytest + pytest-asyncio; files are
tests/test_*.py. - CLI entry points:
kimi/kimi-cli->src/kimi_cli/__main__.py(routes tosrc/kimi_cli/cli/__init__.py). - User config:
~/.kimi/config.toml; logs, sessions, and MCP config live in~/.kimi/.
Git commit messages
Conventional Commits format:
<type>(<scope>): <subject>Allowed types:
feat, fix, test, refactor, chore, style, docs, perf, build, ci, revert.
Versioning
The project follows a minor-bump-only versioning scheme (MAJOR.MINOR.PATCH):
- Patch version is always
0. Never bump it. - Minor version is bumped for any change: new features, improvements, bug fixes, etc.
- Major version is only changed by explicit manual decision; it stays unchanged during normal development.
Examples: 0.68.0 → 0.69.0 → 0.70.0; never 0.68.1.
This rule applies to all packages in the repo (root, packages/*, sdks/*) as well as release
and skill workflows.
Release workflow
For the full procedure, follow the release skill (.agents/skills/release/SKILL.md). The summary:
- Ensure
mainis up to date (pull latest). - Create a release branch, e.g.
bump-0.68orbump-pykaos-0.5.3. - Update
CHANGELOG.md: add a new## 0.68 (YYYY-MM-DD)section below## Unreleased(do not rename## Unreleased). - Update
pyproject.tomlversion. - Run
uv syncto alignuv.lock. - Commit the branch and open a PR.
- Merge the PR, then switch back to
mainand pull latest. - Tag and push:
git tag 0.68orgit tag pykaos-0.5.3git push --tags
- GitHub Actions handles the release after tags are pushed.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository11 other files it gives its agents.
- docs/AGENTS.mdAGENTS.md
- tests_e2e/AGENTS.mdAGENTS.md
- codex-workerSkill
- feature-smoke-testSkill
- gen-changelogSkill
- gen-docsSkill
- gen-rustSkill
- pull-requestSkill
- releaseSkill
- translate-docsSkill
- worktree-statusSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

