1---2name: 05-ai-agent-coding-guidelines-addendum3description: Use when producing or updating AI-agent coding-guidelines addendum for tool schemas, reversibility, blast-radius caps, deterministic state, idempotency, timeouts, and HITL gates. Use coding-guidelines for the neighbouring concern; this skill owns the named document contract and its acceptance evidence.4---567# AI Agent Coding Guidelines Addendum Skill89<!-- dual-compat-start -->10## Use When1112- Produce or update AI-agent coding-guidelines addendum from approved project evidence.13- Resolve decisions about tool schemas, reversibility, blast-radius caps, deterministic state, idempotency, timeouts, and HITL gates.14- Prepare a reviewable handoff for Agent-runtime developers and reviewers.1516## Do Not Use When1718- The task is primarily owned by coding-guidelines; route there and use this skill only for its named output.19- Required project evidence or decision authority is unavailable and the requester expects a pass, release, certification, or production change.2021## Required Inputs2223| Artefact | Source/provider | Required? | Behaviour when absent |24|---|---|---|---|25| Project _context/, approved requirements, and relevant architecture | Project owner and upstream phase skills | Required | Stop at a gap register; do not invent scope, thresholds, integrations, or owners. |26| Existing artefact, implementation, configuration, and evidence named below | Repository, delivery team, or service owner | Required when updating or assessing | Mark inaccessible items `not assessed`; do not treat them as passed. |27| Target audience, environment, risk tolerance, and authority | Requester and accountable owner | Required | Produce a read-only outline with explicit assumptions; do not mutate project or production state. |28## Outputs2930| Artefact | Consumer | Observable acceptance condition |31|---|---|---|32| AI-agent Coding-guidelines Addendum | Agent-runtime developers and reviewers | Every agent tool boundary has schema validation, authority classification, idempotency, timeout, and test obligations. |33| Decision and gap register | Reviewer and downstream phase owner | Every assumption, rejected option, unresolved dependency, waiver, and owner is explicit. |34| Validation evidence | Release or governance reviewer | Checks identify command or method, date, result, evidence location, and all unassessed items. |3536## Evidence Produced3738| Evidence | Minimum content | Acceptance |39|---|---|---|40| Traceability record | Source artefact, decision, output section, owner | No mandatory decision is source-free. |41| Quality-gate result | Check, expected result, observed result, evidence path | Failures and unavailable checks cannot appear as passes. |42| Review record | Reviewer, date, disposition, open actions | The consumer can reproduce the acceptance decision. |4344## Capability and Permission Boundaries4546- Minimum capabilities: read and search the authorised project sources. Execution is optional and limited to non-destructive validation.47- Assessment and planning default to read-only. Create or edit the named project document only when the request explicitly authorises it. Production mutation, publishing, destructive action, spending, external communication, or certification claims require separate explicit authority.48- Treat secrets, tenant data, incident evidence, and financial records as least-privilege inputs; expose only the minimum evidence needed for review.4950## Degraded Mode5152If files, execution, network, rendering, environment access, fonts, or current evidence are unavailable, return the narrowest useful draft plus a gap register. Label affected checks `not assessed`, retain the intended acceptance oracle, and state who must supply or verify the missing evidence. Never convert an unavailable check into a pass.5354## Decision Rules5556| Choice | Action | Failure or risk avoided |57|---|---|---|58| Evidence is complete and authority is explicit | Choose controls by tool reversibility and authorised blast radius and produce the full artefact. | Unsafe autonomous mutations or unreplayable runs. |59| A required source or approval is missing | Stop the affected branch; record the gap, owner, and unblock condition. | Fabricated requirements or unauthorised action. |60| Evidence conflicts across sources | Preserve both claims, identify the controlling owner, and request a recorded decision. | Silent selection of a convenient but wrong source. |61| A check cannot run in the available environment | Keep its oracle and mark it `not assessed`; require later execution evidence. | False assurance from capability limits. |6263## Workflow64651. Confirm the named deliverable, consumer, scope, environment, authority, and neighbouring-skill boundary.662. Inventory required sources and validate provenance, freshness, internal consistency, and missing inputs. Stop the affected branch on a mandatory gap.673. Extract traceable requirements, invariants, risks, and measurable acceptance criteria; record conflicts before choosing a design or procedure.684. Apply the decision rules and the domain workflow below. For a failed branch, preserve evidence, choose the documented recovery path, or escalate to the named owner.695. Draft the artefact, decision register, and evidence record together. Do not defer failure handling, rollback, security, tenancy, accessibility, or operational ownership.706. Run available checks, review every result, repair failures, and hand off only when acceptance is observable. If recovery fails or authority is exceeded, stop and escalate without mutation.7172## Quality Standards7374- Ground every section in a named project source, decision, measured result, or accountable owner.75- Give each requirement or procedure a deterministic oracle that another reviewer can reproduce.76- Keep assumptions, exclusions, degraded checks, residual risks, and waivers visible at handoff.77- Preserve the domain invariants and more specific controls in the existing workflow below; this contract does not replace them.78- Run the repository anti-AI-slop gate: remove filler, verify named standards and dependencies, and retain purposeful domain detail.7980## Anti-Patterns8182- Copying a generic template without mapping it to project sources. Fix: attach each section to an approved requirement, configuration, risk, or owner.83- Choosing a threshold because it is common practice. Fix: derive it from a requirement, measured baseline, risk decision, or current verified source.84- Reporting an inaccessible or unexecuted check as passed. Fix: mark it `not assessed`, preserve the oracle, and name the verifier.85- Mixing the neighbouring coding-guidelines concern into this artefact without a boundary. Fix: cross-reference its output and keep ownership explicit.86- Omitting failure, rollback, empty-state, security, tenancy, or escalation behaviour. Fix: specify the trigger, safe action, verification, and owner for each applicable case.87- Mutating a repository, environment, tenant, ledger, or external system while drafting guidance. Fix: remain read-only until the exact mutation and authority are explicit.88- Claiming compliance, certification, readiness, or release from prose alone. Fix: require source-attributed evidence and a named acceptance decision.8990## Worked Example9192Given an approved project source and a conflicting implementation detail, record both with provenance, stop the affected branch, and obtain the accountable owner's decision. Then update the relevant contract, define a reproducible acceptance check, and retain its observed result. The artefact is accepted only when every agent tool boundary has schema validation, authority classification, idempotency, timeout, and test obligations.9394## References9596- [logic.prompt](logic.prompt) - load only when its template, logic, or detail is needed.97- [README.md](README.md) - load only when its template, logic, or detail is needed.98<!-- dual-compat-end -->99## Core Instructions100101### Step 1: Codify tool-schema discipline102103- Every tool wrapper validates inputs against the catalogue schema at the function boundary; the planner's free-form output is never trusted.104- Outputs from external systems are parsed against the declared output schema and rejected on mismatch.105- Schema validation libraries are pinned and CI-tested.106107### Step 2: Codify irreversibility annotations108109- Every tool function carries a decorator or attribute that names its `reversibility_class`.110- A static-analysis check fails CI if a tool function exists in the codebase without an irreversibility annotation.111- The dispatcher reads the annotation at runtime; mismatch between code annotation and catalogue YAML fails startup.112113### Step 3: Codify blast-radius caps114115- Every tool call inside a single agent run has a per-tool cap (e.g. `email.send` capped at 5 per run).116- Caps are enforced at the dispatcher; the planner does not enforce.117- Per-run caps are loaded from the action catalogue at run start.118119### Step 4: Codify deterministic state120121- Agent run state is `(plan, observations, scratchpad, cumulative_cost)`. State mutations are pure functions of `(previous_state, transition_event)`.122- No tool wrapper is allowed to mutate run state directly; it returns a `ToolResult` that the orchestrator applies to state.123- Replay = re-applying transitions to the initial state in order.124125### Step 5: Codify idempotency keys126127- Every tool call carries `idempotency_key = sha256(agent_run_id + ':' + step_index)`.128- Tool wrappers pass the key to the underlying API where supported.129- Retries reuse the same key. Different idempotency keys on retry are a bug.130131### Step 6: Codify error and timeout policy132133- Every tool wrapper has a default timeout from the catalogue YAML.134- Errors are classified `retryable | non-retryable | safety`.135- `retryable` errors back off (1s, 4s, 16s) with the same idempotency key.136- `non-retryable` errors fail the step; orchestrator decides whether to abstain or re-plan.137- `safety` errors (content-filter trip, kill-switch hit, schema fail) terminate the run; no retry.138139### Step 7: Codify the test contract140141- Every tool wrapper has unit tests against (a) happy path, (b) schema-fail input, (c) timeout, (d) non-retryable error, (e) safety error.142- Every planner change ships with an agent-eval rig run on the affected feature's golden-task set.143- Coverage on agent-runtime code: 90% line coverage; 100% on the dispatcher hot path.144145### Step 8: Write the addendum146147`Coding_Guidelines_Agent_Addendum.md` sections: 1) Tool-Schema Discipline, 2) Irreversibility Annotations, 3) Blast-Radius Caps, 4) Deterministic State, 5) Idempotency Keys, 6) Error & Timeout Policy, 7) Test Contract, 8) Static-Analysis & CI Hooks, 9) Style Examples.148149## Standards150151- OWASP LLM Top 10 (agentic addendum)152- Anthropic agent-engineering patterns153- Google production-LLM playbooks154- IEEE 1016-2009 §5 (Design viewpoints)155156## Resources157158- `logic.prompt`, `README.md`, `references/ai-agent-coding-guidelines-addendum-template.md`.