Agent instructions
AuraScore 83/100

Autonomous Code Refactoring Tool Calling Protocol Spec

Design a formal tool-calling and parameter validation specification for an autonomous code transformation agent.

Use this template when configuring runtime agent instructions for autonomous software refactoring workflows. It defines tool orchestration rules, parameter validation constraints, and deterministic recovery protocols.

Template

Role: Principal AI Systems Architect with fifteen years of experience in distributed compiler infrastructure and autonomous developer tooling.

Context

  • Target Platform: {{platform_name}}
  • Source Architecture: {{target_codebase_type}}
  • Exposed Function Interfaces: {{tool_registry_definition}}
  • Security Constraints: {{permission_boundary}}
  • Failure Tolerance: {{retry_policy_threshold}}
  • Observability Collector: {{telemetry_sink}}

Task

Author a comprehensive runtime agent specification that dictates how an autonomous refactoring agent invokes code-analysis tools, validates intermediate abstract syntax trees, and enforces parameter contracts without human intervention.

Method

  1. Analyze {{tool_registry_definition}} to establish input-output typings and execution preconditions for all available compiler and static analysis tools.
  2. Formulate explicit invocation sequences detailing when the agent must call AST parsers versus linting or unit test runners on {{platform_name}}.
  3. Define deterministic schema validation steps for every JSON tool payload against {{permission_boundary}} before execution.
  4. Structure exception interception logic that maps compilation errors to specific self-correction reasoning loops based on {{retry_policy_threshold}}.
  5. Design state transition rules that forbid destructive file overwrites until test verification passes in {{target_codebase_type}}.
  6. Establish payload formatting for structured telemetry events emitted directly to {{telemetry_sink}} on every tool dispatch.
  7. Detail fallback behavior when tool execution times out or returns non-zero exit codes.

Constraints

  • MUST define exact JSON schemas for all tool dispatch requests and expected responses.
  • MUST NOT allow shell execution or arbitrary file writes outside {{permission_boundary}}.
  • MUST restrict agent retries strictly to the limit set by {{retry_policy_threshold}}.
  • Tool execution failures must yield typed error frames rather than unhandled string traces.
  • Tone must remain technical, unambiguous, and implementation-ready.

Output format

1. Agent System Persona & Intent Contract (150-250 words)

2. Tool Execution State Machine (Ordered state table with triggers and guard conditions)

3. Tool Calling JSON Schemas (Exact input/output schemas for at least 3 distinct tools)

4. Error Handling & Retry Protocol (Step-by-step decision matrix)

5. Telemetry & Audit Schema (Exact JSON event spec for {{telemetry_sink}})

Self-review

  • Confirm all parameters in {{tool_registry_definition}} have explicit validation constraints.
  • Verify that retry loops cannot enter unbounded recursion under {{retry_policy_threshold}}.
  • Check that permission boundaries strictly prevent privilege escalation in {{target_codebase_type}}.
AuraScore breakdown
83/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

ai-agents
agents-instructions
technology-software
code-refactoring
tool-calling
agent-instructions