Role Configuration
Roles are defined in TOML files with the following structure:roles/my_role.toml
Role Fields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier (use snake_case) |
label | string | Yes | Human-readable display name |
description | string | Yes | Brief summary of role purpose and output |
system_prompt | string | Yes | Detailed instructions for the agent |
can_edit | boolean | No | Whether agent can modify files (default: true) |
output | string | No | Output mode: "branch" (code changes) or "artifact" (markdown) (default: "branch") |
Output Modes
Branch mode (output = "branch"):
- Agent produces code changes on a branch
- Changes are merged by the refinery into main
- Default for roles like
feature_developer,bug_fixer,ralph
output = "artifact"):
- Agent produces a markdown report saved to
.enki/artifacts/<exec>/<step>.md - No code changes, no merge step
- Used for read-only roles like
researcher,code_referencer
Role Cascade
Roles load in three layers, with later entries overriding earlier ones byname:
- Built-in roles (defined in
core/src/roles.rs) - Global overrides (
~/.enki/roles/*.toml) - Project overrides (
.enki/roles/*.toml)
- Use built-in roles as-is
- Customize built-in roles globally across all projects
- Override roles per-project for specific needs
Built-in Roles
Enki ships with five built-in roles defined incrates/core/src/roles.rs:
feature_developer
Output: Branch (code changes) When to use: Implementing new features, adding functionality, writing production code. Workflow:- Explore — Study existing codebase patterns
- Design — Choose an implementation approach
- Implement — Write production code and tests
- Self-Review — Check for bugs and consistency
ralph
Output: Branch (code changes) When to use: Tasks with clear programmatic success criteria (tests, builds, linters). Workflow:- Run verification command
- Read the failures
- Fix one thing
- Repeat until everything passes
bug_fixer
Output: Branch (code changes) When to use: Diagnosing and fixing bugs, writing regression tests. Approach:- Find root cause (not symptoms)
- Make minimal surgical fix
- Add regression test
- Verify no collateral damage
researcher
Output: Artifact (markdown report) When to use: Investigating code, tracing execution paths, answering questions about the codebase. Key constraint:can_edit = false — read-only, produces findings report
Built-in researcher role
code_referencer
Output: Artifact (markdown report) When to use: Looking up external code from GitHub repos, fetching documentation, finding reference patterns. Key constraint:can_edit = false — fetches external code but doesn’t modify project files
Use Cases
Read-only Investigation Role
Setcan_edit = false and output = "artifact" for roles that gather information without modifying code:
.enki/roles/security_auditor.toml
Specialized Code Generator
Create focused roles for specific types of code generation:.enki/roles/test_writer.toml
Domain-specific Expert
.enki/roles/db_expert.toml
Tool Access by Role Type
Roles are assigned to one of three MCP tool access tiers based on context:| Tier | Tools | When Used |
|---|---|---|
planner | Full access (task creation, execution control, mail) | Coordinator agent |
worker | Task list, worker_report, edit_file (if can_edit=true), mail | Task execution agents |
worker (no_edit) | Task list, worker_report, mail (no edit_file) | Agents with can_edit=false |
merger | Minimal (status, task list only) | Merge conflict resolution |
can_edit field controls whether workers get the enki_edit_file tool. See MCP Tools for details.
Tips
- Start with built-ins: Clone a similar built-in role and modify it
- Test in isolation: Create a standalone task with your custom role before using it in complex executions
- Be specific: Generic prompts produce generic behavior. Detailed workflows produce consistent results.
- Use phases: Structure multi-step work into numbered phases (Explore → Design → Implement)
- Include examples: Show the agent what good output looks like
- Constrain scope: Narrow roles work better than broad ones
