Skip to content

Defining Roles

Roles define who an agent is. Every agent session is composed from a role definition that sets personality, constraints, and communication style. A role lives in .agents/roles/<name>/ with two files: role.json and ROLE.md.

The role.json schema

{
"name": "engineer",
"description": "Software engineer — implements features, writes tests, fixes bugs",
"capabilities": ["code-generation", "file-editing", "testing", "refactoring"],
"prompt_file": "ROLE.md",
"quality_gates": ["unit-tests", "lint-clean", "no-hardcoded-secrets"],
"skill_refs": [],
"cli": "agent",
"model": "claude-sonnet-4-20250514",
"timeout": 600
}
FieldRequiredDescription
nameyesUnique identifier, matches directory name
descriptionyesOne-line summary shown in role listings
capabilitiesyesTags for skill matching and task routing
prompt_fileyesSystem prompt markdown, relative to role dir
quality_gatesnoChecks QA applies when reviewing output
skill_refsnoSkills auto-loaded for every session
clinoCLI tool to spawn the agent (agent, opencode)
modelnoDefault LLM model, overridden by plan config
timeoutnoMax seconds per session (default: 600)

Creating a role

  1. Create the directory. mkdir -p .agents/roles/security-auditor

  2. Write role.json with name, capabilities, and quality gates.

  3. Write ROLE.md — this becomes the agent’s system prompt.

  4. Test the role by referencing it in a plan epic.

Writing effective ROLE.md files

---
name: security-auditor
description: You are a Security Auditor...
tags: [security, audit, review]
trust_level: core
---
# Your Responsibilities
Primary job description.
## Workflow
Step-by-step process.
## Communication
How to use channel tools.
## Quality Standards
Non-negotiable rules.

Capability tags

Capabilities control skill matching and task routing:

CapabilityTypical roles
code-generationengineer, architect
code-reviewqa, security-auditor
testingengineer, qa
architecturearchitect
documentationtechnical-writer

Quality gates

Quality gates tell QA what to check when reviewing this role’s output:

"quality_gates": ["unit-tests", "lint-clean", "no-hardcoded-secrets", "api-docs-updated"]

Forking an existing role

  1. Copy the role directory. cp -r .agents/roles/engineer .agents/roles/backend-engineer

  2. Update role.json. Change name, description, and adjust capabilities.

  3. Customize ROLE.md. Remove irrelevant instructions, add domain-specific workflows.

  4. Reference in your plan.

    ## Epic 2: API Layer
    ### Roles
    - backend-engineer

Built-in roles

RolePurpose
engineerGeneral-purpose implementation
architectSystem design and technical decisions
qaTesting and quality validation
managerOrchestration, triage, coordination
reporterDocumentation and report generation
technical-writerDocumentation specialist

Role resolution order

The engine resolves role names in this order:

  1. Project .agents/roles/<name>/ (local override)
  2. Global ~/.ostwin/.agents/roles/<name>/ (installed roles)
  3. Built-in roles shipped with OSTwin

The first match wins, letting you override global roles per-project.