---
title: "audit"
description: "Record what happened and why"
canonical: "https://acs.synapti.ai/capabilities/audit/"
last_updated: "2026-11-26T08:26:27+01:00"
---

# audit

Record what happened and why

Generated from [schemas/capability_ontology.yaml](https://github.com/synaptiai/agent-capability-standard/blob/main/schemas/capability_ontology.yaml), [skills/audit/SKILL.md](https://github.com/synaptiai/agent-capability-standard/blob/main/skills/audit/SKILL.md) at commit 18c38b74ac21. Ontology version 2.2.0.

Layer: [VERIFY](https://acs.synapti.ai/layers/verify/index.md)

## Safety

| Property | Value |
| --- | --- |
| Risk | Low |
| Changes state | Yes |
| Needs checkpoint | No |
| Needs approval | No |
| Overridable | Yes |
| Blocked from autonomy | No |

In a workflow, verify, where the workflow has it, must come first (V102).

## Relationships

**Figure: Relationships of audit: 5 relationships with 5 capabilities.** audit has 5 relationships with 5 capabilities: 5 with edges into it.

| Capability | Row | Relationships |
| --- | --- | --- |
| [`explain`](https://acs.synapti.ai/capabilities/explain/index.md) | Edges into audit | `enables` (into) |
| [`execute`](https://acs.synapti.ai/capabilities/execute/index.md) | Edges into audit | `enables` (into) |
| [`mutate`](https://acs.synapti.ai/capabilities/mutate/index.md) | Edges into audit | `enables` (into) |
| [`verify`](https://acs.synapti.ai/capabilities/verify/index.md) | Edges into audit | `precedes` (into) |
| [`constrain`](https://acs.synapti.ai/capabilities/constrain/index.md) | Edges into audit | `enables` (into) |

- `enables`: Unlocked by [`execute`](https://acs.synapti.ai/capabilities/execute/index.md), [`mutate`](https://acs.synapti.ai/capabilities/mutate/index.md), [`constrain`](https://acs.synapti.ai/capabilities/constrain/index.md), [`explain`](https://acs.synapti.ai/capabilities/explain/index.md)
- `precedes`: Comes after, when both are present [`verify`](https://acs.synapti.ai/capabilities/verify/index.md)

## Contract

**Figure: Contract of audit: 4 inputs (1 required), 9 outputs.** audit takes 4 inputs, 1 required (filled pin) and 3 optional (hollow pin), and returns 9 outputs. The tables below list every field.

### Inputs

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `event` | object | Yes | What happened, as the step reports it. The implementation records it, whatever its shape, as details.event of an action record of its own (capability audit), whose recorded_by and chain fields it sets itself; no member of the event becomes a member of that record (Standard v1.2 §6.4). |
| `context` | object | No | Event context |
| `retention` | string | No | How long the record is to be kept in the store it is written to, a duration (Standard v1.2 §5.10.1, e.g. 2555d or P30D); absent, the store's own policy applies (§6.3). A literal outside the grammar is W614. |
| `require_record` | boolean | No | The record must be written. When true, the step fails (R402, reason not_recorded) unless the output's recorded is true (Standard v1.2 §6.4). Default false. |

### Outputs

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `recorded` | boolean | Yes | Whether the record was written. |
| `audit_id` | string | No | Audit record ID |
| `record` | object | No | The action record written for the event (Standard v1.2 §6.4). |
| `store` | object | No | Where the record was written, so a workflow can tell whether it outlives the session (Standard v1.2 §6.3, §6.6) |
| `store.name` | string | No | The store, as the host documents it |
| `store.durability` | string | No | memory - lost when its process ends; session - deleted with the session or thread; durable - kept until its retention removes it One of: memory, session, durable |
| `store.retention` | string | No | The retention the store applies to the record, a duration (§5.10.1); absent when it keeps records until they are removed by hand |
| `timestamp` | string | No | Format: date-time |
| `evidence_anchors` | array of Anchor (or deprecated string or object) | Yes | What the output is based on, as evidence anchors (Standard v1.2 §6.5). An empty list grounds nothing, and the output is then marked inferred (§3.1). |
| `confidence` | number | No | The producer's probability that the output's claim is correct, self-reported; given when the output is inferred (Standard v1.2 §3.1, §4.1.1) From 0 to 1 |
| `inference_method` | string | No | How the output was reached when it is not grounded in evidence; with confidence it marks the output inferred (Standard v1.2 §3.1, §4.1.1). A producer should use model_knowledge, deduction, induction, abduction, analogy, statistical, simulation, assumption or an x- vendor value; a grounding policy (§5.20) requires one of them. |
| `uncertainty` | Uncertainty | No | The uncertainty of the output's principal value; its confidence equals the output's confidence (Standard v1.2 §4.1.1) |

The skill returns 13 fields: 7 are in audit's output contract (2 required) and 6 are the skill's own, outside the contract; it leaves out 2 contract fields (inference_method, uncertainty).

| Field of the skill's output | In the output contract |
| --- | --- |
| `recorded` | Yes, required |
| `record` | Yes, optional |
| `store` | Yes, optional |
| `audit_id` | Yes, optional |
| `timestamp` | Yes, optional |
| `audit_record` | No, the skill's own |
| `changes` | No, the skill's own |
| `tool_usage` | No, the skill's own |
| `decision_rationale` | No, the skill's own |
| `provenance` | No, the skill's own |
| `confidence` | Yes, optional |
| `evidence_anchors` | Yes, required |
| `assumptions` | No, the skill's own |
| `inference_method` | Yes, but the skill leaves it out |
| `uncertainty` | Yes, but the skill leaves it out |

## Used in workflows

**Figure: audit in workflows.** 27 workflows use audit, in 27 steps in all; its steps are the squares in an ink ring, and the key under the strips names the other squares.

- [`monitor_and_replan`](https://acs.synapti.ai/workflows/monitor-and-replan/index.md): step 7
- [`clarify_intent`](https://acs.synapti.ai/workflows/clarify-intent/index.md): step 5
- [`debug_code_change`](https://acs.synapti.ai/workflows/debug-code-change/index.md): step 11
- [`world_model_build`](https://acs.synapti.ai/workflows/world-model-build/index.md): step 10
- [`capability_gap_analysis`](https://acs.synapti.ai/workflows/capability-gap-analysis/index.md): step 7
- [`digital_twin_sync_loop`](https://acs.synapti.ai/workflows/digital-twin-sync-loop/index.md): step 20
- [`rag_pipeline`](https://acs.synapti.ai/workflows/rag-pipeline/index.md): step 7
- [`security_assessment`](https://acs.synapti.ai/workflows/security-assessment/index.md): step 7
- [`multi_agent_orchestration`](https://acs.synapti.ai/workflows/multi-agent-orchestration/index.md): step 7
- [`data_quality_pipeline`](https://acs.synapti.ai/workflows/data-quality-pipeline/index.md): step 7
- [`model_deployment`](https://acs.synapti.ai/workflows/model-deployment/index.md): step 8
- [`data_pipeline_validation`](https://acs.synapti.ai/workflows/data-pipeline-validation/index.md): step 12
- [`anomaly_investigation`](https://acs.synapti.ai/workflows/anomaly-investigation/index.md): step 11
- [`report_generation`](https://acs.synapti.ai/workflows/report-generation/index.md): step 11
- [`model_monitoring`](https://acs.synapti.ai/workflows/model-monitoring/index.md): step 13
- [`patient_monitoring`](https://acs.synapti.ai/workflows/patient-monitoring/index.md): step 12
- [`clinical_alert_triage`](https://acs.synapti.ai/workflows/clinical-alert-triage/index.md): step 11
- [`care_plan_review`](https://acs.synapti.ai/workflows/care-plan-review/index.md): step 12
- [`handoff_preparation`](https://acs.synapti.ai/workflows/handoff-preparation/index.md): step 13
- [`production_line_monitoring`](https://acs.synapti.ai/workflows/production-line-monitoring/index.md): step 9
- [`quality_control_loop`](https://acs.synapti.ai/workflows/quality-control-loop/index.md): step 9
- [`predictive_maintenance`](https://acs.synapti.ai/workflows/predictive-maintenance/index.md): step 10
- [`supply_chain_sync`](https://acs.synapti.ai/workflows/supply-chain-sync/index.md): step 11
- [`schedule_management`](https://acs.synapti.ai/workflows/schedule-management/index.md): step 10
- [`information_research`](https://acs.synapti.ai/workflows/information-research/index.md): step 11
- [`task_delegation`](https://acs.synapti.ai/workflows/task-delegation/index.md): step 9
- [`communication_drafting`](https://acs.synapti.ai/workflows/communication-drafting/index.md): step 10

## Claude Code skill

**Figure: What the audit skill's tools can do, against the ontology.** The skill may use 3 tools: 2 only read and 1 run commands; the ontology marks audit as changing state, and Bash can make the change.

| What they can do | Tools |
| --- | --- |
| Only read | `Read`, `Grep` |
| Run commands, which can change state | `Bash` |
| Change files | none |

**Figure: The field names each step of the audit procedure uses.** 7 of the procedure's 7 steps use the name of an input or output field of the audit skill as a word; 3 output fields of 13 are used by no step (timestamp, tool_usage, confidence).

| Step | Inputs it uses by name | Output fields it uses by name |
| --- | --- | --- |
| 1. Define audit scope | `event`, `context` | `changes` |
| 2. Collect action records |  | `changes` |
| 3. Extract decision rationale |  | `decision_rationale`, `assumptions` |
| 4. Build provenance chain |  | `provenance` |
| 5. Ground claims |  | `record`, `audit_id`, `evidence_anchors` |
| 6. Write the record (append-only) | `event` | `recorded`, `record`, `audit_record`, `assumptions` |
| 7. Format output |  | `recorded`, `record`, `store` |

Both examples of the skill write out the same 11 of its 13 output fields, and neither writes out record and store.

**Figure: The field names each verification check of the audit skill uses.** 2 of the 4 checks use the name of an input or output field as a word; 9 output fields of 13 are named by no check (record, store, timestamp, audit_record, tool_usage, decision_rationale, provenance, confidence and assumptions).

| Check | Inputs it uses by name | Output fields it uses by name |
| --- | --- | --- |
| 1. Evidence Grounding: All changes linked to evidence_anchors |  | `changes`, `evidence_anchors` |
| 2. Contract Validation: Output has recorded, audit_id and evidence_anchors per the output schema |  | `recorded`, `audit_id`, `evidence_anchors` |
| 3. Completeness Check: No gaps in timeline for the specified time window |  |  |
| 4. Provenance Valid: All inputs and outputs are verifiable |  |  |

**Figure: The neighbours the skill lists for audit, checked against the ontology and the catalogs.** The skill lists 6 capabilities as common neighbours of audit; 4 of them have an edge with it in the ontology, and 3 run next to it, in that order, in a catalog workflow (rollback most often, 3 times). Under each tile, an edge reads from its source to its target, with audit's symbol in its place: "requires Ad" is a requires edge from the tile's capability to audit, so the tile's capability must run before audit; "Ad precedes" is a precedes edge from audit to the tile's capability.

| Listed as | Capability | Ontology edge | Next to it in a workflow |
| --- | --- | --- | --- |
| commonly follows | [`verify`](https://acs.synapti.ai/capabilities/verify/index.md) | `precedes` | 1 times |
| commonly follows | [`execute`](https://acs.synapti.ai/capabilities/execute/index.md) | `enables` | never |
| commonly follows | [`mutate`](https://acs.synapti.ai/capabilities/mutate/index.md) | `enables` | never |
| commonly follows | [`rollback`](https://acs.synapti.ai/capabilities/rollback/index.md) | none | 3 times |
| commonly precedes | [`explain`](https://acs.synapti.ai/capabilities/explain/index.md) | `enables` | 1 times |
| commonly precedes | [`persist`](https://acs.synapti.ai/capabilities/persist/index.md) | none | never |

### Live Context

Current audit context:

- Recent git commits: !`git log --oneline -10 2>/dev/null || echo "No git history"`
- Git authors today: !`git log --since="midnight" --format="%an" 2>/dev/null | sort | uniq -c || echo "None"`
- Uncommitted changes: !`git status --short 2>/dev/null || echo "Not a git repo"`
- Recent file modifications: !`find . -type f -mtime -1 -not -path './.git/*' 2>/dev/null | wc -l | tr -d ' '` files in last 24h
- Tool-call log exists: !`wc -l "${CLAUDE_PROJECT_DIR:-.}/.claude/audit.log" 2>/dev/null || echo "No .claude/audit.log"`
- Audit records exist: !`wc -l "${CLAUDE_PROJECT_DIR:-.}/.claude/audit/records.jsonl" 2>/dev/null || echo "No .claude/audit/records.jsonl"`
- Checkpoint log exists: !`ls -la .checkpoints/ 2>/dev/null | head -5 || echo "No .checkpoints/ directory"`

### Intent

Execute **audit** to create a structured record of actions taken, tools invoked, changes made, and the reasoning behind decisions. This provides accountability, enables investigation of issues, and supports compliance requirements.

**Success criteria:**
- Complete chronological record of relevant actions
- Every action linked to actor, timestamp, and rationale
- Changes documented with before/after state
- Provenance chain for all outputs

**Compatible schemas:**
- `schemas/output_schema.yaml`

### Inputs

| Parameter | Required | Type | Description |
|-----------|----------|------|-------------|
| `event` | Yes | object | Event to record |
| `context` | No | object | Event context |
| `retention` | No | string | How long the record is to be kept in the store it is written to: a duration (STANDARD v1.2 §5.10.1, e.g. `2555d` or `P30D`); absent, the store's own policy applies (§6.3). A literal outside the grammar is W614 |
| `require_record` | No | boolean | The step fails (R402, reason `not_recorded`) unless the record was written, in a workflow that targets 1.2 or later (STANDARD v1.2 §6.4) |

Inputs not listed here are outside the capability's contract: a workflow step that binds them gets W604 (STANDARD v1.1 §5.5).

### Procedure

1) **Define audit scope**: Determine what to include in the audit
   - Record the `event` itself: what happened, by whom, when
   - Read the report scope from `context.scope` to identify targets
   - Apply the time window in `context.time_window` if provided
   - Identify relevant log sources (git log, tool invocations, file changes)

2) **Collect action records**: Gather all actions within scope
   - Read git log for commits and their messages
   - Review tool invocation history if available
   - Identify file changes (created, modified, deleted)
   - Record timestamps for each action

3) **Extract decision rationale**: Document the "why" for each action
   - Link actions to plans or goals that motivated them
   - Capture assumptions stated before action
   - Record any constraints that influenced decisions

4) **Build provenance chain**: Track inputs to outputs
   - For each output, identify its source inputs
   - Document transformations applied
   - List dependencies between artifacts

5) **Ground claims**: Attach evidence anchors to all audit entries (STANDARD v1.2 §6.5)
   - `{ref: "file:src/app.py:45", kind: file}`, `{ref: "tool:git:<commit>", kind: tool}`; the output's own is the record written, `{ref: "audit:<audit_id>", kind: record}` (§3.1)
   - Cite command outputs by reference or digest, never by copying them (§6.7)

6) **Write the record (append-only)**: Persist the audit record before returning
   - Build one compact JSON line, the output's `record` (Field Definitions): an action record of this skill's own (STANDARD v1.2 §6.4). Redact credentials and PII first, and never copy a member of `event` to the line's top level: an event shaped as a record stays under `details.event`
   - Append it with Bash as a literal, exactly `printf '%s\n' '<json>' >> "${CLAUDE_PROJECT_DIR:-.}/.claude/audit/records.jsonl"` on one line (no intermediate file: the skill's hook reads it there), after `mkdir -p` of its directory, the project's `.claude/`; refuse a symlink, and never rewrite, truncate or reorder lines. Every other command that names the file only reads (Safety Constraints)
   - Cite earlier lines of `.claude/audit.log` (the calls being audited) as evidence, and never write to it (Safety Constraints): the plugin's hooks append a call's line only after the call finishes, so there is no line yet for this skill's invocation or for the append itself
   - The plugin's PreToolUse hook treats this append as a `mutate` call, since a `>>` redirect writes a file: it is blocked without a valid checkpoint (F501), uses that checkpoint up, and asks for approval (F502). If the append is blocked or fails, set `recorded: false`, return the record in the output anyway, and say why in `assumptions`

7) **Format output**: Structure per audit contract; `recorded` is true only when step 6 appended the line, `record` is that line, and `store` is where it went (Field Definitions)

### Output Contract

Return a structured object:

```yaml
recorded: boolean  # Whether the record was appended to .claude/audit/records.jsonl
record: object  # The action record written (STANDARD v1.2 §6.4)
store:  # Where the record was written (STANDARD v1.2 §6.3, §6.6)
  name: string  # e.g. .claude/audit/records.jsonl
  durability: memory | session | durable  # never durable for a store that does not outlive the session
  retention: string | null  # the duration the store applies (§5.10.1); absent when it keeps records until removed by hand
audit_id: string  # Unique audit record ID
timestamp: string  # ISO 8601 date-time the audit record was generated
audit_record:
  actor: string  # Who/what performed audited actions
  action_type: string  # Category of actions
  targets: array[string]  # What was affected
  outcome: success | failure | partial
changes:
  - type: string  # create, modify, delete, execute
    before: string | null  # Previous state/value
    after: string | null  # New state/value
    location: string  # File path or identifier
    timestamp: string  # When change occurred
tool_usage:
  - tool: string  # Tool name
    invocation_count: integer
    success_rate: number  # 0.0-1.0
    commands: array[string]  # Actual commands if verbose
decision_rationale: string  # Why these actions were taken
provenance:
  inputs: array[string]  # Source data/files
  outputs: array[string]  # Produced artifacts
  dependencies: array[string]  # External dependencies used
confidence: number  # probability that the record was appended as reported (§4.1.1)
evidence_anchors: [{ref: "audit:<audit_id>", kind: record}, {ref: "tool:git:...", kind: tool}, {ref: "file:...", kind: file}]  # the record written grounds the output (STANDARD v1.2 §3.1)
assumptions: []
```

#### Field Definitions

| Field | Type | Description |
|-------|------|-------------|
| `recorded` | boolean | Whether the record was appended to `.claude/audit/records.jsonl` (false when the write was blocked or failed) |
| `record` | object | The action record of step 6: `action_id` (the `audit_id`), `timestamp`, `actor: agent`, `intent` (the event's `intent`, else its `event_type`, when a string; else `audit`), `status: executed`, `capability: audit`, `details` (`event`, `context` and `retention` when given, and the collected `audit_record`, `changes` and `provenance`), `recorded_by: {"name": "audit skill"}`, then `prev_hmac` (the `hmac` of the file's last line, empty for the first) and `hmac` (HMAC-SHA-256, as lowercase hex, of the line without `hmac` as `jq -c` prints it, with `openssl dgst -sha256 -hmac` under `AUDIT_HMAC_KEY` where the skill's commands have it; without it, the record is written unsigned, with `hmac` empty, which a workflow can test as `${a.record.hmac} == ""`: the key file the plugin's hook prefers, `~/.config/acs/audit.key`, is kept out of the agent's reach, and no key is derived from anything else). After a line whose `hmac` is empty, the next line's `prev_hmac` is empty. When the last line has no `hmac` member (a line written before Standard 1.2, which does not verify), do not chain onto it: move the file aside (`records.<UTC time>.jsonl`, same directory) and start a new one, whose first line has `prev_hmac` empty. Each member of `event` stays under `details.event`: it is what the step reported, and cannot claim another writer, an actor, an approval or a place in the chain |
| `store` | object | Where the record was written: the store's `name`, its `durability` (`memory`, `session` or `durable`; a store that does not outlive the session is never reported `durable`) and the `retention` it applies, so a workflow can stop on `${a.store.durability} != 'durable'` (STANDARD v1.2 §6.3, §6.6). This skill's is `{name: ".claude/audit/records.jsonl", durability: durable}`, a file in the project kept until removed by hand, with no `retention` |
| `audit_id` | string | Unique identifier for this audit record |
| `timestamp` | string | ISO 8601 date-time the audit record was generated |
| `audit_record.actor` | string | Who performed the actions |
| `audit_record.outcome` | enum | Overall result of audited actions |
| `changes` | array | List of all changes with before/after |
| `tool_usage` | array | Summary of tools invoked |
| `decision_rationale` | string | Explanation of why actions were taken |
| `provenance` | object | Input/output/dependency lineage |
| `confidence` | number | Probability, 0.0-1.0, that the record was appended as reported (§4.1.1) |
| `evidence_anchors` | array of evidence anchors (§6.5) | References to source evidence |
| `assumptions` | array | What was assumed during audit collection |

### Examples

#### Example 1: Audit Code Change Session

**Input:**
```yaml
event:
  type: session_completed
  actor: "claude-agent"
  timestamp: "2024-01-15T16:00:00Z"
context:
  scope: "session"
  time_window:
    start: "2024-01-15T14:00:00Z"
    end: "2024-01-15T16:00:00Z"
  detail_level: standard
  include_diffs: false
```

**Output:**
```yaml
recorded: true
audit_id: "audit_20240115_160000_session"
timestamp: "2024-01-15T16:00:00Z"
audit_record:
  actor: "claude-agent"
  action_type: "code_modification"
  targets:
    - "src/api/handlers/user.py"
    - "src/api/handlers/auth.py"
    - "tests/test_handlers.py"
  outcome: success
changes:
  - type: modify
    before: "get_user() with inline SQL"
    after: "get_user() with parameterized query"
    location: "src/api/handlers/user.py:45-62"
    timestamp: "2024-01-15T14:45:00Z"
  - type: modify
    before: "5 test cases"
    after: "7 test cases (added SQL injection tests)"
    location: "tests/test_handlers.py"
    timestamp: "2024-01-15T15:15:00Z"
tool_usage:
  - tool: Read
    invocation_count: 12
    success_rate: 1.0
  - tool: Edit
    invocation_count: 4
    success_rate: 1.0
  - tool: Bash
    invocation_count: 3
    success_rate: 1.0
    commands: ["pytest tests/", "git diff", "git commit"]
decision_rationale: "Refactored to prevent SQL injection vulnerability identified in security audit. Added parameterized queries and corresponding test coverage."
provenance:
  inputs:
    - "security_audit_report.md"
    - "src/api/handlers/user.py (original)"
  outputs:
    - "src/api/handlers/user.py (modified)"
    - "tests/test_handlers.py (modified)"
  dependencies:
    - "pytest>=7.0"
    - "psycopg2"
confidence: 0.95
evidence_anchors:
  - {ref: "audit:audit_20240115_160000_session", kind: record}
  - {ref: "file:.claude/audit/records.jsonl", kind: file}
  - {ref: "tool:git:abc123def456", kind: tool}
  - {ref: "tool:bash:pytest tests/ - 7 passed", kind: tool}
  - {ref: "file:src/api/handlers/user.py:45", kind: file}
assumptions:
  - "Git log accurately reflects all changes"
  - "No manual edits outside of tracked session"
```

**The line step 6 appends** (with `AUDIT_HMAC_KEY=example-key`; `python tools/verify_audit_log.py --log-file .claude/audit/records.jsonl --no-head --hmac-key "$AUDIT_HMAC_KEY"`, run outside Claude Code, checks the chain, which no head anchors, with the key the records were signed under: without `--hmac-key` the verifier uses the key file, `~/.config/acs/audit.key`, when it exists, and every signed record fails. Records written without `AUDIT_HMAC_KEY` are unsigned, and the verifier reports each one):

```json
{"action_id":"audit_20240115_160000_session","timestamp":"2024-01-15T16:00:00Z","actor":"agent","intent":"audit","status":"executed","capability":"audit","details":{"event":{"type":"session_completed","actor":"claude-agent","timestamp":"2024-01-15T16:00:00Z"},"context":{"scope":"session"},"audit_record":{"actor":"claude-agent","action_type":"code_modification","targets":["src/api/handlers/user.py"],"outcome":"success"},"changes":[{"type":"modify","location":"src/api/handlers/user.py:45-62","timestamp":"2024-01-15T14:45:00Z"}],"provenance":{"inputs":["security_audit_report.md"],"outputs":["src/api/handlers/user.py"],"dependencies":[]}},"recorded_by":{"name":"audit skill"},"prev_hmac":"","hmac":"67bcae7663853fd55f9d77492b9612e9a2ee77b91331995e964eefb17db4d90a"}
```

**Evidence pattern:** Git commit history, tool invocation logs, file diffs.

---

#### Example 2: Audit Specific File Changes

**Input:**
```yaml
event:
  type: configuration_changed
  actor: "claude-agent"
  target: "config/production.yaml"
context:
  scope: "config/production.yaml"
  detail_level: verbose
  include_diffs: true
```

**Output:**
```yaml
recorded: true
audit_id: "audit_20240115_config"
timestamp: "2024-01-15T17:00:00Z"
audit_record:
  actor: "claude-agent"
  action_type: "configuration_change"
  targets:
    - "config/production.yaml"
  outcome: failure
changes:
  - type: modify
    before: |
      database:
        host: db.internal
        port: 5432
    after: |
      database:
        host: db.external
        port: 5433
    location: "config/production.yaml:12-15"
    timestamp: "2024-01-15T15:30:00Z"
  - type: rollback
    before: "(modified config)"
    after: "(original config)"
    location: "config/production.yaml"
    timestamp: "2024-01-15T16:00:00Z"
tool_usage:
  - tool: Edit
    invocation_count: 2
    success_rate: 0.5
decision_rationale: "Attempted database migration to external host. Rollback triggered after connection test failed."
provenance:
  inputs:
    - "migration_plan.md"
    - "config/production.yaml (original)"
  outputs:
    - "config/production.yaml (restored to original)"
  dependencies: []
confidence: 1.0
evidence_anchors:
  - {ref: "audit:audit_20240115_config", kind: record}
  - {ref: "file:.claude/audit/records.jsonl", kind: file}
  - {ref: "file:.checkpoints/chk_20240115_150000_config/manifest.json", kind: file}
  - {ref: "tool:bash:rollback command output", kind: tool}
assumptions: []
```

### Verification

Apply the following verification patterns:

- [ ] **Evidence Grounding**: All changes linked to evidence_anchors
- [ ] **Contract Validation**: Output has `recorded`, `audit_id` and `evidence_anchors` per the output schema
- [ ] **Completeness Check**: No gaps in timeline for the specified time window
- [ ] **Provenance Valid**: All inputs and outputs are verifiable

**Verification tools:** Read (for log files and the appended record), Grep (for searching history), Bash (to append the record)

### Safety Constraints

- `mutation`: true (it writes an audit record); `mutation_overridable`, so a step that only reads may declare `mutation: false`
- `requires_checkpoint`: false
- `requires_approval`: false
- `risk`: low

**Capability-specific rules:**
- Never modify audited artifacts during audit
- Preserve original timestamps (do not alter history)
- Include failed actions, not just successes
- Redact sensitive information (credentials, PII) from audit output
- Store audit records append-only: only ever append to `"${CLAUDE_PROJECT_DIR:-.}/.claude/audit/records.jsonl"`; never edit or delete earlier lines, and never write to the hook-maintained `.claude/audit.log` (the plugin's PostToolUse and PostToolUseFailure hooks keep it as an HMAC-chained log of every tool call, checked by `tools/verify_audit_log.py`, and a foreign line would break the chain)
- Only step 6's append writes the records file. Any other Bash command that names the records file, `.claude` or the audit directory (or runs there, or holds a glob that may match the file) only reads: the skill's hook refuses one that redirects output to a file, runs a program but `cat`, `echo`, `printf`, `jq`, `ls`, `head`, `tail`, `wc`, `grep`, `cut`, `tr`, `base64`, `sha256sum`, `shasum`, `md5sum`, `date`, `hostname`, `sleep`, `test`, `true`, `false`, `pwd`, `cd`, `stat`, `basename`, `dirname`, `mkdir`, `openssl dgst` and the `mv` that moves the file aside, or substitutes a command (`$(...)`); so compute the HMAC in a command of its own, and write values literally. An Edit or a Write of the file is refused too
- No credential in a record (STANDARD v1.2 §6.7): the skill's PreToolUse command hook blocks an append whose line holds what looks like one, read with its JSON escapes resolved, or any value but a placeholder (`<ref>`) under a member named for a credential (`"password": "hunter2"`, `"token": 4111111111111111`) (`F504 CONSTRAINT_VIOLATED:`, §5.18.10); rewrite the line to cite the value by reference or digest, then append again
- A literal record (§5.18.10): the hook reads the record only in step 6's form, one JSON object on one line with no single quote, and refuses (F504) any other command naming the records file that holds `$` (but in `${CLAUDE_PROJECT_DIR:-.}`), a backtick, `\`, `<` or `>`, which could build its text when the command runs. Compute the HMAC, and a moved-aside file's time, in commands of their own, then write them literally

### Composition Patterns

**Commonly follows:**
- `verify` - After verify passes (`passed: true`), audit the successful changes (CAVR pattern)
- `execute` / `mutate` - Audit what was executed
- `rollback` - Audit the rollback event itself

**Commonly precedes:**
- `explain` - Summarize audit for stakeholder reporting
- `persist` - Store audit record for compliance

**Anti-patterns:**
- Never skip audit after `execute` or `mutate` (breaks accountability)
- Never modify artifacts during audit (breaks integrity)
- Never omit failed actions from audit trail

**Workflow references:**
- See `reference/composition_patterns.md#debug-code-change` for audit-after-verify
- See `reference/composition_patterns.md#digital-twin-sync-loop` for audit in loops
