policy-engine-builder
Guide for creating Gemini CLI policy engine TOML rules. Covers rule syntax, priority tiers, conditions, and MCP wildcards. Use when restricting Gemini tools, creating security policies, controlling MCP server permissions, or setting up approval workflows.
What this skill does
# Policy Engine Builder
## ๐จ MANDATORY: Invoke gemini-cli-docs First
> **STOP - Before providing ANY response about Gemini policy engine:**
>
> 1. **INVOKE** `gemini-cli-docs` skill
> 2. **QUERY** for the specific policy topic
> 3. **BASE** all responses EXCLUSIVELY on official documentation loaded
## Overview
This skill provides guidance for configuring Gemini CLI's Policy Engine using TOML rules. The policy engine controls tool execution with fine-grained allow/deny/ask rules.
## When to Use This Skill
**Keywords:** policy engine, policy toml, tool policy, allow deny, gemini rules, security policy, mcp policy
**Use this skill when:**
- Restricting which tools Gemini can use
- Creating enterprise security policies
- Controlling MCP server permissions
- Setting up approval workflows
- Auditing tool execution rules
## Policy File Locations
### User Policies
```text
~/.gemini/policies/
โโโ default.toml # User default rules
โโโ security.toml # Additional security rules
```
### Project Policies
```text
.gemini/policies/
โโโ project.toml # Project-specific rules
โโโ team.toml # Team conventions
```
### System Policies (Enterprise)
```text
/etc/gemini-cli/policies/ # Linux
/Library/Application Support/GeminiCli/policies/ # macOS
C:\ProgramData\gemini-cli\policies\ # Windows
```
## Rule Structure
### Basic Rule
```toml
[[rule]]
toolName = "run_shell_command"
decision = "ask_user"
priority = 100
```
### Rule Fields
| Field | Type | Description |
| --- | --- | --- |
| `toolName` | string/array | Tool name(s) to match |
| `mcpName` | string | MCP server name |
| `argsPattern` | string | Regex for tool arguments |
| `commandPrefix` | string/array | Shell command prefix(es) |
| `commandRegex` | string | Regex for shell commands |
| `decision` | string | `allow`, `deny`, or `ask_user` |
| `priority` | number | 0-999 within tier |
| `modes` | array | Optional: `yolo`, `autoEdit` |
## Decision Types
### Allow
Automatically approve without prompting:
```toml
[[rule]]
toolName = "read_file"
decision = "allow"
priority = 100
```
### Deny
Block execution entirely:
```toml
[[rule]]
toolName = "run_shell_command"
commandPrefix = "rm -rf"
decision = "deny"
priority = 999
```
### Ask User
Prompt for confirmation:
```toml
[[rule]]
toolName = "write_file"
decision = "ask_user"
priority = 100
```
## Priority System
### Three Tiers
| Tier | Base | Source |
| --- | --- | --- |
| Default | 1 | Built-in defaults |
| User | 2 | User policies |
| Admin | 3 | System/enterprise |
### Priority Calculation
The formula is: `final_priority = tier_base + (toml_priority / 1000)`
Example:
- User rule with priority 100 โ 2 + (100/1000) = 2.100
- Admin rule with priority 50 โ 3 + (50/1000) = 3.050
**Higher tier always wins**, then higher priority within tier.
### Priority Guidelines
| Priority | Use Case |
| --- | --- |
| 0-99 | Low priority defaults |
| 100-499 | Normal rules |
| 500-799 | Important restrictions |
| 800-999 | Critical security rules |
## Tool Matching
### Single Tool
```toml
[[rule]]
toolName = "run_shell_command"
decision = "ask_user"
```
### Multiple Tools
```toml
[[rule]]
toolName = ["write_file", "replace"]
decision = "ask_user"
```
### All Tools
```toml
[[rule]]
toolName = "*"
decision = "ask_user"
```
## Shell Command Patterns
### Command Prefix
```toml
# Match commands starting with "git"
[[rule]]
toolName = "run_shell_command"
commandPrefix = "git "
decision = "allow"
priority = 100
```
### Multiple Prefixes
```toml
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["npm ", "yarn ", "pnpm "]
decision = "allow"
priority = 100
```
### Command Regex
```toml
# Match destructive commands
[[rule]]
toolName = "run_shell_command"
commandRegex = "^(rm|rmdir|del|rd)\\s"
decision = "deny"
priority = 999
```
## Argument Patterns
### JSON Argument Matching
Tool arguments are JSON strings:
```toml
# Deny writes to sensitive paths
[[rule]]
toolName = "write_file"
argsPattern = ".*\\.(env|key|pem|crt)$"
decision = "deny"
priority = 900
```
### Complex Patterns
```toml
# Allow reads only from src/
[[rule]]
toolName = "read_file"
argsPattern = "^\\{\"path\":\"src/.*\"\\}$"
decision = "allow"
priority = 100
```
## MCP Server Rules
### Server-Level Control
```toml
# Deny all tools from untrusted server
[[rule]]
mcpName = "untrusted-server"
decision = "deny"
priority = 500
```
### Tool-Level Control
```toml
# Allow specific tool from server
[[rule]]
mcpName = "my-server"
toolName = "safe_tool"
decision = "allow"
priority = 100
```
### Wildcards
```toml
# All tools from server pattern
[[rule]]
toolName = "my-server__*"
decision = "ask_user"
priority = 100
```
## Approval Modes
### YOLO Mode Rules
Apply only in YOLO mode (`--yolo`):
```toml
[[rule]]
toolName = "write_file"
decision = "allow"
modes = ["yolo"]
priority = 100
```
### Auto-Edit Mode Rules
Apply in auto-edit mode:
```toml
[[rule]]
toolName = "replace"
decision = "allow"
modes = ["autoEdit"]
priority = 100
```
## Template Library
### Secure Development Environment
```toml
# Allow read operations
[[rule]]
toolName = ["read_file", "glob", "search_file_content", "list_directory"]
decision = "allow"
priority = 100
# Ask for writes
[[rule]]
toolName = ["write_file", "replace"]
decision = "ask_user"
priority = 100
# Allow safe git commands
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["git status", "git diff", "git log", "git branch"]
decision = "allow"
priority = 200
# Ask for other git commands
[[rule]]
toolName = "run_shell_command"
commandPrefix = "git "
decision = "ask_user"
priority = 150
# Deny destructive commands
[[rule]]
toolName = "run_shell_command"
commandRegex = "^(rm|rmdir|del|rd|format|mkfs)\\s"
decision = "deny"
priority = 999
```
### Read-Only Mode
```toml
# Allow all reads
[[rule]]
toolName = ["read_file", "glob", "search_file_content", "list_directory", "web_fetch"]
decision = "allow"
priority = 100
# Deny all writes
[[rule]]
toolName = ["write_file", "replace", "run_shell_command"]
decision = "deny"
priority = 500
```
### NPM/Node.js Safe
```toml
# Allow npm read commands
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["npm list", "npm outdated", "npm audit"]
decision = "allow"
priority = 200
# Ask for npm install/run
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["npm install", "npm run", "npm exec"]
decision = "ask_user"
priority = 150
# Deny npm publish
[[rule]]
toolName = "run_shell_command"
commandPrefix = "npm publish"
decision = "deny"
priority = 900
```
### MCP Server Restrictions
```toml
# Deny all external MCP servers by default
[[rule]]
toolName = "*__*"
decision = "deny"
priority = 100
# Allow specific trusted server
[[rule]]
mcpName = "trusted-internal-server"
decision = "allow"
priority = 200
# Allow specific tools from another server
[[rule]]
toolName = ["other-server__read_docs", "other-server__search"]
decision = "allow"
priority = 200
```
### Enterprise Lockdown
```toml
# System-level (Admin tier)
# Block all network access
[[rule]]
toolName = ["web_fetch", "google_web_search"]
decision = "deny"
priority = 999
# Block all MCP servers
[[rule]]
toolName = "*__*"
decision = "deny"
priority = 999
# Allow only reads
[[rule]]
toolName = ["read_file", "glob", "search_file_content"]
decision = "allow"
priority = 100
# Block all shell commands except safe ones
[[rule]]
toolName = "run_shell_command"
decision = "deny"
priority = 500
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["ls ", "cat ", "echo ", "pwd"]
decision = "allow"
priority = 600
```
## Validation
### Check TOML Syntax
```bash
python -c "import tomllib; tomllib.load(open('policy.toml', 'rb'))"
```
### Common Errors
| Error | Cause | Fix |
| --- | --- | --- |
| Parse error | Invalid TOML | Check quotes, brackets |
| Rule ignored | Lower priority | Increase priority |
| Rule conflicts | Overlapping patterns | Refine patterns |
| Regex Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts โ single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score โฅ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.