Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/kilo-docs/lib/nav/customize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export const CustomizeNav: NavSection[] = [
children: "Custom Subagents",
platform: "new",
},
{
href: "/customize/agent-permissions",
children: "Agent Permissions",
platform: "new",
},
{ href: "/customize/agents-md", children: "agents.md" },
{ href: "/customize/workflows", children: "Workflows", platform: "new" },
{ href: "/customize/skills", children: "Skills" },
Expand Down
189 changes: 189 additions & 0 deletions packages/kilo-docs/pages/customize/agent-permissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
---
title: "Agent Permissions"
description: "Configure Kilo Code agent permission rules for tools, shell commands, files, and subagents"
platform: new
---

# Agent Permissions

Agent permissions decide whether a tool call is allowed, asks for approval, or is denied.

This page focuses on Markdown agent files, where permission rules are written as YAML frontmatter under the `permission` key. For global defaults in `kilo.jsonc`, use the JSON examples in [Auto-Approving Actions](/docs/getting-started/settings/auto-approving-actions#glob-pattern-rules).

## Actions

Each permission rule uses one of these actions:

| Action | Behavior |
|---|---|
| `allow` | Run the matching tool call without asking. |
| `ask` | Prompt before running the matching tool call. |
| `deny` | Block the matching tool call. |

You can write each permission as one action for the whole tool or as a pattern map:

```yaml
Comment thread
singhvishalkr marked this conversation as resolved.
Resolved
permission:
read: allow
edit:
"*": deny
"*.md": allow
bash:
"*": ask
"git status *": allow
```

## Rule Precedence
Comment thread
singhvishalkr marked this conversation as resolved.
Resolved

Permission rules are evaluated in config order. When more than one rule matches the requested permission and target pattern, the last matching rule wins.

Put broad fallbacks first and exceptions after them:

```yaml
permission:
bash:
"*": ask
"uv *": allow
```

With that config, `uv pip install ...` is allowed because `uv *` appears after the catch-all `*`.

If you put the catch-all last, it overrides the earlier specific rule:

```yaml
permission:
bash:
"uv *": allow
"*": ask
```

With that config, `uv pip install ...` asks because the later `*` rule also matches.

Top-level permission keys follow the same rule. For example, this lets `bash` override the global fallback:

```yaml
permission:
"*": ask
bash: allow
```

This does the opposite because the top-level `*` is later:

```yaml
permission:
bash: allow
"*": ask
```

## Patterns

Permission patterns use glob matching:

| Pattern | Matches |
|---|---|
| `*` | Any target for that permission. |
| `git *` | `git`, `git status`, `git log --oneline`, and other `git` commands. |
| `git status *` | `git status` with or without extra arguments. |
| `src/*` | Paths under `src/`. |
| `*.env` | Files ending in `.env`, including nested paths such as `apps/web/.env`. |

The matcher normalizes Windows backslashes to forward slashes before matching. On Windows, matching is case-insensitive; on Unix-like systems, matching is case-sensitive. Prefer forward slashes in config because they work across platforms.

`~`, `~/...`, `$HOME`, and `$HOME/...` at the start of a pattern are expanded to your home directory when the config is loaded.

## File Paths

File tools such as `read`, `edit`, and `write` resolve the input path first, then check permissions against the path relative to the current worktree.

For project files, use workspace-relative patterns:

```yaml
permission:
read:
"*": ask
"docs/*": allow
"src/generated/*": deny
edit:
"*": deny
"*.md": allow
```

Absolute paths are mainly relevant for `external_directory` permissions and shell commands that touch paths outside the worktree.

## Shell Commands

The `bash` permission is checked against parsed shell command patterns. If a shell block contains multiple parsed commands, each relevant command must be permitted. A single denied command rejects the request.

For example:

```yaml
permission:
bash:
"*": ask
"cd *": allow
"git *": deny
```

For this command:

```bash
cd "/project"; git status
```

Kilo checks the parsed command patterns. The `git status` command matches `git *`, so the request is denied. Directory changes and commands that access paths outside the worktree can also trigger `external_directory` checks.

Built-in read-only agents include additional shell restrictions for write-like patterns such as output redirection, command substitution, pipes, and command chains. If you create your own read-only agent, prefer an explicit deny fallback and allow only the commands you trust:

```yaml
permission:
bash:
"*": deny
"cat *": allow
"grep *": allow
"git status *": allow
"git diff *": allow
```

## Sensitive Files

Kilo treats `.env` and `.env.*` reads as sensitive. Broad read approvals, such as `read: allow`, `read: { "*": allow }`, saved wildcard approvals, or allow-everything mode do not bypass the built-in prompt for these files. `.env.example` is treated as safe documentation and can be allowed by default.

Use explicit sensitive-file rules only when you intentionally want that behavior for a specific agent:

```yaml
permission:
read:
"*": allow
"*.env": ask
"*.env.*": ask
"*.env.example": allow
```

## Subagent Delegation

Use `task` permission rules to control which subagents another agent may invoke:

```yaml
permission:
task:
"*": deny
"code-reviewer": allow
"docs-writer": allow
```

This allows delegation only to `code-reviewer` and `docs-writer`.

## Troubleshooting

- If a specific rule appears to be ignored, check whether a later catch-all also matches.
- If a broad allow does not apply to `.env`, this is expected sensitive-file protection.
- If a shell command asks unexpectedly, check whether it was parsed into more than one command pattern or triggered `external_directory`.
- If path rules behave differently across operating systems, write patterns with forward slashes and workspace-relative paths where possible.

## Related

- [Custom Modes](/docs/customize/custom-modes)
- [Custom Subagents](/docs/customize/custom-subagents)
- [Auto-Approving Actions](/docs/getting-started/settings/auto-approving-actions)
- [.kilocodeignore](/docs/customize/context/kilocodeignore)
- [Tool Use Overview](/docs/automate/tools)
2 changes: 1 addition & 1 deletion packages/kilo-docs/pages/customize/custom-subagents.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ The `permission` field controls what tools the subagent can use. Each tool permi
}
```

For bash commands, you can use glob patterns to set permissions per command. Rules are evaluated in order, with the **last matching rule winning**.
For bash commands, you can use glob patterns to set permissions per command. Rules are evaluated in order, with the **last matching rule winning**. See [Agent Permissions](/docs/customize/agent-permissions) for rule precedence, shell command patterns, path matching, and sensitive-file behavior.

You can also control which subagents an agent can invoke via `permission.task`:

Expand Down
1 change: 1 addition & 0 deletions packages/kilo-docs/pages/customize/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Configure how Kilo Code behaves and responds:
- [**Custom Rules**](/docs/customize/custom-rules) - Define rules that apply to specific file types or situations
- [**Custom Instructions**](/docs/customize/custom-instructions) - Add project-specific guidelines and context
- [**Custom Subagents**](/docs/customize/custom-subagents) - Create specialized subagents with custom prompts, models, and permissions
- [**Agent Permissions**](/docs/customize/agent-permissions) - Configure rule precedence, shell command patterns, file paths, and subagent delegation
- [**agents.md**](/docs/customize/agents-md) - Configure agent behavior at the project level
- [**Workflows**](/docs/customize/workflows) - Automate multi-step processes
- [**Skills**](/docs/customize/skills) - Extend Kilo's capabilities with reusable skill definitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,40 @@ Permissions are configured under the `permission` key in `kilo.jsonc`. The follo

Instead of a simple `"allow"` or `"deny"`, each tool can use glob-pattern rules for granular control. Patterns are matched against the tool's arguments (command strings, file paths, etc.), and the last matching rule wins.

### Rule Precedence

Permission rules are evaluated in config order. When more than one rule matches the requested permission and target pattern, the last matching rule wins.
Comment thread
singhvishalkr marked this conversation as resolved.
Resolved

Put broad fallbacks first and exceptions after them:

```json
{
"permission": {
"bash": {
"*": "ask",
"uv *": "allow"
}
}
}
```

With that config, `uv pip install ...` is allowed because `uv *` appears after the catch-all `*`.

If you put the catch-all last, it overrides the earlier specific rule:

```json
{
"permission": {
"bash": {
"uv *": "allow",
"*": "ask"
}
}
}
```

With that config, `uv pip install ...` asks because the later `*` rule also matches.

### Example: Shell Commands

Allow git commands automatically, but prompt for everything else:
Expand All @@ -133,8 +167,8 @@ Allow git commands automatically, but prompt for everything else:
{
"permission": {
"bash": {
"git *": "allow",
"*": "ask"
"*": "ask",
"git *": "allow"
}
}
}
Expand All @@ -148,8 +182,8 @@ Prompt before reading `.env` files, but allow all other reads:
{
"permission": {
"read": {
"*.env": "ask",
"*": "allow"
"*": "allow",
"*.env": "ask"
}
}
}
Expand All @@ -163,11 +197,11 @@ Deny `rm -rf` commands, allow common dev commands, and ask for anything else:
{
"permission": {
"bash": {
"*": "ask",
"rm -rf *": "deny",
"npm *": "allow",
"bun *": "allow",
"git *": "allow",
"*": "ask"
"git *": "allow"
}
}
}
Expand All @@ -185,7 +219,7 @@ Different agents can have different permission levels. Override the default perm
"agent": {
"code": {
"permission": {
"bash": { "git *": "allow", "*": "ask" }
"bash": { "*": "ask", "git *": "allow" }
}
},
"plan": {
Expand All @@ -199,6 +233,26 @@ Different agents can have different permission levels. Override the default perm

In this example, the `code` agent can run `git` commands automatically and asks for other shell commands, while the `plan` agent cannot run shell commands at all.

## Markdown Agent Files

If you define agents in Markdown files, the `permission` frontmatter uses the same `allow` / `ask` / `deny` values and glob patterns as `kilo.jsonc`:

```markdown
---
description: Reviews code for quality and best practices
mode: subagent
permission:
bash:
"*": ask
"git *": allow
read:
"*": allow
"*.env": ask
---
```

This is the same permission shape described in [Agent Permissions](/docs/customize/agent-permissions), just shown in the agent-file format.

## Runtime Permission Requests

When a tool is set to `"ask"`, Kilo pauses and displays a permission prompt. You have three options:
Expand Down Expand Up @@ -234,12 +288,12 @@ This is a custom example showing the available configuration options — it does
```json
{
"permission": {
"read": { "*.env": "ask", "*": "allow" },
"edit": { "*.env": "ask", "*": "allow" },
"read": { "*": "allow", "*.env": "ask" },
"edit": { "*": "allow", "*.env": "ask" },
"glob": { "*": "allow" },
"grep": { "*": "allow" },
"list": { "*": "allow" },
"bash": { "git *": "allow", "npm *": "allow", "*": "ask" },
"bash": { "*": "ask", "git *": "allow", "npm *": "allow" },
"task": { "*": "allow" },
"skill": { "*": "allow" },
"lsp": { "*": "allow" },
Expand All @@ -253,7 +307,7 @@ This is a custom example showing the available configuration options — it does
"agent": {
"code": {
"permission": {
"bash": { "git *": "allow", "npm *": "allow", "*": "ask" }
"bash": { "*": "ask", "git *": "allow", "npm *": "allow" }
}
}
}
Expand Down
Loading