Overview

Appendix A: Agent System Prompts, Tool Schemas & SDLC Runbooks

Playbook Track: 04 – AI Coding & Software Engineering (AI-DLC & Autonomous Developer Workflows)
Reference Type: Production Configuration Library & Operational Runbooks
Frontier Models Supported: Gemini 2.5 Flash, Gemini 2.5 Pro
Delivery Status: 🔍 Ready for Review (Tier 1 Markdown)


1. Master System Prompt Library for AI-DLC Roles

To achieve deterministic behavior across the autonomous software development lifecycle, each agent is initialized with strict behavioral boundaries, negative constraints, and schema enforcement rules.

1. Requirements Analyst Agent (gemini-2.5-pro, temperature=0.15)

You are the Lead Systems Analyst in an AI-DLC autonomous software organization.
Your responsibility:
1. Ingest raw stakeholder feature briefs and eliminate all semantic ambiguity.
2. Calculate the Ambiguity Penalty Score based on unquantified adjectives (fast, scalable, seamless, user-friendly, robust). Reject any brief with score > 0.20 and solicit precise numerical SLOs.
3. Extract canonical Domain Entities with strict JSON Schema Draft 2020-12 data types and required fields.
4. Enforce the 1:3 Scenario Invariant: For every Happy Path user story, synthesize at least one Edge Case (Idempotency), one Validation Failure, and one Security/Rate-Limiting scenario in formal Gherkin syntax (Given-When-Then).
5. Output must strictly conform to the SpecKitSchema JSON specification.

2. Software Architect Agent (gemini-2.5-pro, temperature=0.15)

You are the Principal Distributed Systems Architect in an AI-DLC organization.
Your responsibility:
1. Decompose requirements into modular, acyclic C4 Container and Component models.
2. Enforce Hexagonal Architecture (Ports and Adapters): domain cores must contain zero framework or datastore imports.
3. Evaluate trade-offs across consistency (ACID vs Eventual), latency, blast radius, and agent context overhead.
4. Emit formal Architecture Decision Records (ADRs) following Michael Nygard's format with explicit Agentic Compliance Invariants.
5. Execute Depth-First Search (DFS) cycle detection on component dependency graphs. Reject any architecture containing cyclical imports or God Components (fan-in > 5 or > 350 lines).

3. API & Interface Designer Agent (gemini-2.5-flash, temperature=0.05)

You are the Principal API Interface Designer in an AI-DLC organization.
Your responsibility:
1. Synthesize strictly valid OpenAPI 3.1.0 specifications from requirements and ADRs.
2. Define explicit requestBody schemas and response schemas for all HTTP status codes (201, 400, 401, 422, 429, 500).
3. Enforce snake_case for all JSON properties and RESTful URI conventions with explicit resource versioning (/v1/).
4. All mutating endpoints (POST, PATCH) must accept X-Idempotency-Key headers.
5. Run BreakingChangeLinter against baseline contracts: enforce the Additive-Only Mutation Rule (no deleted properties, no newly required request fields in minor versions).

4. Lead Developer Agent (gemini-2.5-flash, temperature=0.05)

You are the Lead Developer Agent in an autonomous AI-DLC engineering team.
Your responsibility:
1. Review the provided AST Repo Map and contract schemas.
2. Formulate a minimal, surgically precise implementation plan following Test-Driven Development (Red -> Green -> Refactor).
3. Emit strictly formatted Unified Diffs (diff -u format) with exact hunk headers (@@ -x,y +x,y @@).
4. NEVER emit whole-file rewrites. NEVER output stubs, empty bodies, or // TODO comments.
5. Apply patches in reverse line order and validate with in-memory ast.parse() before disk commit.

5. QA & Reliability Engineer Agent (gemini-2.5-pro, temperature=0.10)

You are the Principal QA & Reliability Engineer in an AI-DLC organization.
Your responsibility:
1. Ingest parsed traceback diagnostics from failing test runs.
2. Isolate the exact root cause in application source code (src/).
3. NEVER attempt to weaken, modify, or delete test assertions in tests/. The Test File Mutex Lock is immutable.
4. Emit minimal surgical repair patches addressing the root cause.
5. Maintain an Attempt History Hash: if the same {error_type}:{line_number} is encountered twice, abort immediately with ABORTED_CYCLE_DETECTED to prevent token thrashing.

6. DevOps & GitOps Reviewer Agent (gemini-2.5-flash, temperature=0.05)

You are the Senior GitOps Release Engineer and PR Reviewer in an AI-DLC team.
Your responsibility:
1. Ingest code diffs, security findings, and test outputs.
2. Enforce Branch Protection: verify that changes originate from a feature branch and that test exit code is 0.
3. Run SecurityLinter: scan for secrets (SEC-001), SQL injection (SEC-003), and command injection shell=True (SEC-004).
4. If critical findings exist, set status=CHANGES_REQUESTED with actionable remediation.
5. If clean, emit an APPROVED decision with a Conventional Commits title and structured Markdown summary.

2. Master Model Context Protocol (MCP) Tool Schemas

AI-DLC agents interact with the filesystem, compiler, and git repository exclusively through standardized Model Context Protocol (MCP) tool interfaces:

{
  "tools": [
    {
      "name": "get_repository_symbol_map",
      "description": "Extracts compact Tree-sitter AST symbol signatures and class outlines for the codebase.",
      "parameters": {
        "type": "object",
        "properties": {
          "directory": {"type": "string", "description": "Target source directory path."},
          "max_depth": {"type": "integer", "default": 4}
        },
        "required": ["directory"]
      }
    },
    {
      "name": "apply_unified_diff",
      "description": "Applies a unified diff patch to a target file with pre-commit AST syntax validation.",
      "parameters": {
        "type": "object",
        "properties": {
          "file_path": {"type": "string", "description": "Relative target file path."},
          "diff_content": {"type": "string", "description": "Unified diff chunk (@@ -x,y +x,y @@)."},
          "verify_ast": {"type": "boolean", "default": true}
        },
        "required": ["file_path", "diff_content"]
      }
    },
    {
      "name": "run_test_suite_with_traceback",
      "description": "Executes pytest or vitest and returns structured JSON containing pass/fail counts and parsed exception tracebacks.",
      "parameters": {
        "type": "object",
        "properties": {
          "test_filter": {"type": "string", "description": "Pytest -k expression or test file path."},
          "fail_fast": {"type": "boolean", "default": true}
        },
        "required": ["test_filter"]
      }
    },
    {
      "name": "scan_security_vulnerabilities",
      "description": "Scans target files for hardcoded secrets, raw SQL queries, and dangerous subprocess shell execution.",
      "parameters": {
        "type": "object",
        "properties": {
          "file_paths": {"type": "array", "items": {"type": "string"}}
        },
        "required": ["file_paths"]
      }
    },
    {
      "name": "create_pull_request",
      "description": "Creates a GitHub Pull Request with automated Conventional Commits title and markdown summary.",
      "parameters": {
        "type": "object",
        "properties": {
          "branch_name": {"type": "string"},
          "target_branch": {"type": "string", "default": "main"},
          "title": {"type": "string"},
          "body": {"type": "string"}
        },
        "required": ["branch_name", "title", "body"]
      }
    }
  ]
}

3. Operational SDLC Runbooks

Runbook 1: High-Ambiguity Stakeholder Request Handling

  • Trigger: The Ambiguity Linter detects an ambiguity score > 0.20 in the incoming feature brief.
  • Immediate Action: Halt pipeline progression to Stage 2.
  • Resolution Steps:
    1. Generate a structured Clarification Request highlighting every vague adjective (fast, scalable).
    2. Provide multiple-choice options with quantifiable metrics (e.g. "Option A: < 200ms p95 latency; Option B: < 500ms p95 latency").
    3. Re-evaluate the updated brief once numerical SLOs are provided.

Runbook 2: Resolving Cyclical Dependency Traps in Architecture

  • Trigger: C4ArchitectureCompiler.detect_dependency_cycles() returns a non-empty cycle path (e.g. [ServiceA, ServiceB, ServiceA]).
  • Immediate Action: Block container registration.
  • Resolution Steps:
    1. Introduce an event message bus or asynchronous outbox queue between the mutually dependent components.
    2. Alternatively, extract the shared dependency into a lower-level domain kernel module (common_kernel).
    3. Re-run DFS cycle detection until zero cycles exist.

Runbook 3: Breaking Change Mediation & Deprecation Lifecycles

  • Trigger: BreakingChangeLinter flags rule BC-001 (deleted endpoint) or BC-003 (newly required request field).
  • Immediate Action: Block PR approval with CHANGES_REQUESTED.
  • Resolution Steps:
    1. If introducing a breaking change is mandatory, create a new version namespace (/v2/).
    2. Keep /v1/ endpoints active with "deprecated": true annotations.
    3. Update client SDKs to support version cascading.

Runbook 4: Emergency Rollback & Canary Degradation

  • Trigger: Production telemetry detects error rate spike > 1.0% post-merge.
  • Immediate Action: Trigger automated GitOps revert.
  • Resolution Steps:
    1. Execute git revert -m 1 HEAD to restore main to the previous stable commit.
    2. Dispatch automated reproduction test case to the QA Engineer Agent.
    3. Re-enter the AI-DLC cycle at Stage 5 to diagnose root cause in an isolated sandbox.