Skip to content
Docs menu

Tool reference · Errors, rules & self-improvement

self_rules_context

Returns the active rules that apply to the current project, optionally narrowed to rules for the current task phase.

local stdio server read-only
Caution. Not purely read-only: each returned rule has its fire_count incremented, which feeds its success rate.

When to use

  • At the start of a session, to load the rules the agent should follow.
  • You are entering a specific phase (plan, build, reflect) and only want rules for it.
  • You are working on a task that matches certain error categories and want their rules too.

Parameters

NameTypeDefaultDescription
project string "general" —
categories string[] — Error categories relevant to current task
phase "van" | "plan" | "creative" | "build" | "reflect" | "archive" — Optional: lazy-load only rules relevant to this phase (core + phase-specific). Omit to get all rules.

Example

Arguments

{
  "project": "my-api",
  "phase": "build"
}

Result shape

{
  "rules_count": 1,
  "rules": [
    {
      "id": 19,
      "content": "Always run the migration in a transaction on staging first.",
      "category": "config_error",
      "scope": "project:my-api",
      "priority": 7,
      "success_rate": 0.8,
      "tags": "[\"phase:build\"]"
    }
  ],
  "phase_filter": "build"
}

Returns at most 20 rules: global ones plus those scoped to the project or to the given categories.

Values are illustrative; the keys follow the server's handler. MCP clients receive the result as JSON text content.

Server description

The description the server sends to your agent in tools/list, captured from the v14.7.0 source:

Get active behavioral rules for current session. Call at SESSION START to load rules. Returns rules filtered by project and scope. v8.0: pass `phase` to lazy-load rules relevant to current task phase — core rules (no phase tag) + rules tagged phase:<X>. Cuts prompt tokens ~70%. After task completion, rate rules: self_rules(action='rate', id=X, success=true/false).

Found a mistake? Open an issue on GitHub.

Search