---
title: "execute"
description: "Run code or script deterministically"
canonical: "https://acs.synapti.ai/capabilities/execute/"
last_updated: "2026-11-16T01:14:10Z"
---

# execute

Run code or script deterministically

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

Layer: [EXECUTE](https://acs.synapti.ai/layers/execute/index.md)

## Safety

| Property | Value |
| --- | --- |
| Risk | Medium |
| Changes state | No |
| Needs checkpoint | No |
| Needs approval | Yes |
| Overridable | No |
| Blocked from autonomy | In 1 of 7 profiles |

**Figure: Ordering rules for execute in a workflow.** In a workflow, constrain should run before it (W601); plan and constrain, where the workflow has them, must come first (V102); where the workflow has verify, execute must come before it (V102); and each use needs approval.

| Where | Capability | Rule | Enforcement | Diagnostic |
| --- | --- | --- | --- | --- |
| Before execute | [`plan`](https://acs.synapti.ai/capabilities/plan/index.md) | `precedes` | MUST | V102 |
| Before execute | [`constrain`](https://acs.synapti.ai/capabilities/constrain/index.md) | `soft_requires` | SHOULD | W601 |
| Before execute | [`constrain`](https://acs.synapti.ai/capabilities/constrain/index.md) | `precedes` | MUST | V102 |
| Approval | Each use needs approval | `requires_approval` |  |  |
| After execute | [`verify`](https://acs.synapti.ai/capabilities/verify/index.md) | `precedes` | MUST | V102 |

## Relationships

**Figure: Relationships of execute: 6 relationships with 4 capabilities.** execute has 6 relationships with 4 capabilities: 2 with edges into it and 2 with edges out of it.

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

- `soft_requires`: Recommended after [`constrain`](https://acs.synapti.ai/capabilities/constrain/index.md)
- `enables`: Unlocks [`audit`](https://acs.synapti.ai/capabilities/audit/index.md)
- `enables`: Unlocked by [`plan`](https://acs.synapti.ai/capabilities/plan/index.md)
- `precedes`: Comes before, when both are present [`verify`](https://acs.synapti.ai/capabilities/verify/index.md)
- `precedes`: Comes after, when both are present [`plan`](https://acs.synapti.ai/capabilities/plan/index.md), [`constrain`](https://acs.synapti.ai/capabilities/constrain/index.md)

## Contract

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

### Inputs

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string | Yes | Code to execute |
| `language` | string | No | Programming language |
| `timeout` | string | No | Execution timeout |
| `environment` | object | No | Execution environment |

### Outputs

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `result` | any | Yes | Execution result |
| `stdout` | string | No | Standard output |
| `stderr` | string | No | Standard error |
| `exit_code` | integer | No |  |
| `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 7 fields: 5 are in execute's output contract (2 required) and 2 are the skill's own, outside the contract; it leaves out 3 contract fields (confidence, inference_method, uncertainty).

| Field of the skill's output | In the output contract |
| --- | --- |
| `result` | Yes, required |
| `exit_code` | Yes, optional |
| `stdout` | Yes, optional |
| `stderr` | Yes, optional |
| `execution` | No, the skill's own |
| `analysis` | No, the skill's own |
| `evidence_anchors` | Yes, required |
| `confidence` | Yes, but the skill leaves it out |
| `inference_method` | Yes, but the skill leaves it out |
| `uncertainty` | Yes, but the skill leaves it out |

## Used in workflows

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

- [`debug_code_change`](https://acs.synapti.ai/workflows/debug-code-change/index.md): step 8
- [`digital_twin_sync_loop`](https://acs.synapti.ai/workflows/digital-twin-sync-loop/index.md): step 17
- [`model_deployment`](https://acs.synapti.ai/workflows/model-deployment/index.md): step 4

## Claude Code skill

**Figure: What the execute skill's tools can do, against the ontology.** The skill may use 2 tools: 1 only read and 1 run commands; the ontology marks execute as read-only, so Bash is more than the capability needs.

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

**Figure: The field names each step of the execute procedure uses.** 6 of the procedure's 6 steps use the name of an input or output field of the execute skill as a word; 3 output fields of 7 are used by no step (result, analysis, evidence_anchors).

| Step | Inputs it uses by name | Output fields it uses by name |
| --- | --- | --- |
| 1. Validate execution request | `code`, `timeout`, `environment` | `execution` |
| 2. Prepare environment | `environment` | `execution` |
| 3. Execute code | `code`, `timeout` | `stdout`, `stderr` |
| 4. Capture results | `code` | `exit_code`, `stdout`, `stderr`, `execution` |
| 5. Analyze output | `code` | `exit_code` |
| 6. Return results |  | `execution` |

All 3 examples of the skill write out every one of its 7 output fields.

**Figure: The field names each verification check of the execute skill uses.** 2 of the 5 checks use the name of an input or output field as a word; 5 output fields of 7 are named by no check (result, stdout, execution, analysis and evidence_anchors).

| Check | Inputs it uses by name | Output fields it uses by name |
| --- | --- | --- |
| 1. Exit code is captured | `code` | `exit_code` |
| 2. Stdout and stderr are both recorded |  | `stderr` |
| 3. Duration is reasonable |  |  |
| 4. Analysis summary matches output |  |  |
| 5. No mutations occurred |  |  |

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

| Listed as | Capability | Ontology edge | Next to it in a workflow |
| --- | --- | --- | --- |
| commonly follows | [`plan`](https://acs.synapti.ai/capabilities/plan/index.md) | `enables`, `precedes` | never |
| commonly follows | [`generate`](https://acs.synapti.ai/capabilities/generate/index.md) | none | never |
| commonly follows | [`transform`](https://acs.synapti.ai/capabilities/transform/index.md) | none | never |
| commonly precedes | [`verify`](https://acs.synapti.ai/capabilities/verify/index.md) | `precedes` (into it) | 3 times |
| commonly precedes | [`detect`](https://acs.synapti.ai/capabilities/detect/index.md) | none | never |
| commonly precedes | [`audit`](https://acs.synapti.ai/capabilities/audit/index.md) | `enables` (into it) | never |

### Intent

Execute code or commands in a controlled manner, capturing output for verification. Unlike `mutate`, this capability is for operations that don't permanently change state (tests, queries, builds, analysis tools).

**Success criteria:**
- Code/command executed successfully
- Output captured completely
- Exit code recorded
- Errors properly surfaced

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

### Inputs

| Parameter | Required | Type | Description |
|-----------|----------|------|-------------|
| `code` | Yes | string | Code or command to execute |
| `language` | No | string | Programming language or shell (bash, python, ruby, etc.) |
| `timeout` | No | string | Maximum execution time (default: "60s") |
| `environment` | No | object | Environment variables to set |

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) **Validate execution request**: Ensure code is safe to run
   - Check for mutation operations (if found, suggest `mutate` instead)
   - Verify timeout is reasonable
   - Confirm execution environment

2) **Prepare environment**: Set up execution context
   - Set required environment variables
   - Ensure dependencies are available
   - Create isolated context if needed

3) **Execute code**: Run the code/command
   - Capture stdout and stderr
   - Record start time
   - Monitor for timeout

4) **Capture results**: Collect execution output
   - Record exit code
   - Capture complete stdout
   - Capture complete stderr
   - Note execution duration

5) **Analyze output**: Interpret results
   - Identify success/failure from exit code
   - Extract key information from output
   - Note warnings or anomalies

6) **Return results**: Structure output for consumption
   - Include all captured data
   - Provide execution summary
   - Reference evidence for assertions

### Output Contract

Return a structured object:

```yaml
result:
  success: boolean  # Exit code == 0
  duration: string  # Execution time
exit_code: integer  # Process exit code
stdout: string  # Standard output
stderr: string  # Standard error
execution:
  command: string  # What was executed
  language: string  # Execution environment
  started_at: string  # ISO timestamp
  completed_at: string  # ISO timestamp
analysis:
  summary: string  # One-line result summary
  warnings: array[string]  # Notable warnings
  errors: array[string]  # Extracted error messages
evidence_anchors: [{ref: "command:output", kind: tool}]
```

#### Field Definitions

| Field | Type | Description |
|-------|------|-------------|
| `result` | any | Execution result: here `success` and `duration` |
| `result.success` | boolean | Whether execution succeeded |
| `result.duration` | string | How long execution took |
| `exit_code` | integer | Process exit code |
| `stdout` | string | Standard output |
| `stderr` | string | Standard error |
| `execution` | object | Execution metadata |
| `analysis` | object | Interpreted results |
| `evidence_anchors` | array of evidence anchors (§6.5) | References to the command and its output |

### Examples

#### Example 1: Run Tests

**Input:**
```yaml
code: "npm test -- --grep 'UserService'"
language: "bash"
timeout: "120s"
```

**Output:**
```yaml
result:
  success: true
  duration: "2.3s"
exit_code: 0
stdout: |
  > project@1.0.0 test
  > jest --grep 'UserService'

  PASS src/services/__tests__/UserService.test.ts
    UserService
      ✓ creates user with valid data (45ms)
      ✓ validates email format (12ms)
      ✓ hashes password on save (23ms)

  Test Suites: 1 passed, 1 total
  Tests:       3 passed, 3 total
stderr: ""
execution:
  command: "npm test -- --grep 'UserService'"
  language: "bash"
  started_at: "2024-01-15T10:30:00Z"
  completed_at: "2024-01-15T10:30:02Z"
analysis:
  summary: "3 tests passed in UserService"
  warnings: []
  errors: []
evidence_anchors:
  - {ref: "command:npm test:output", kind: tool}
```

#### Example 2: Execute Query

**Input:**
```yaml
code: "SELECT COUNT(*) as user_count FROM users WHERE created_at > '2024-01-01'"
language: "sql"
environment:
  DATABASE_URL: "${DATABASE_URL}"
```

**Output:**
```yaml
result:
  success: true
  duration: "0.15s"
exit_code: 0
stdout: |
  user_count
  ----------
  15423
  (1 row)
stderr: ""
execution:
  command: "psql -c \"SELECT COUNT(*)...\""
  language: "sql"
  started_at: "2024-01-15T10:35:00Z"
  completed_at: "2024-01-15T10:35:00Z"
analysis:
  summary: "Query returned 15423 users created in 2024"
  warnings: []
  errors: []
evidence_anchors:
  - {ref: "command:psql:query_result", kind: tool}
```

#### Example 3: Execution Failure

**Input:**
```yaml
code: "python -c 'import nonexistent_module'"
language: "bash"
```

**Output:**
```yaml
result:
  success: false
  duration: "0.05s"
exit_code: 1
stdout: ""
stderr: |
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  ModuleNotFoundError: No module named 'nonexistent_module'
execution:
  command: "python -c 'import nonexistent_module'"
  language: "bash"
  started_at: "2024-01-15T10:40:00Z"
  completed_at: "2024-01-15T10:40:00Z"
analysis:
  summary: "Import failed: module 'nonexistent_module' not found"
  warnings: []
  errors:
    - "ModuleNotFoundError: No module named 'nonexistent_module'"
evidence_anchors:
  - {ref: "command:python:error", kind: tool}
```

### Verification

- [ ] Exit code is captured
- [ ] Stdout and stderr are both recorded
- [ ] Duration is reasonable
- [ ] Analysis summary matches output
- [ ] No mutations occurred

**Verification tools:** Bash (to verify command execution environment)

### Safety Constraints

- `mutation`: false
- `requires_checkpoint`: false
- `requires_approval`: true
- `risk`: medium

**Capability-specific rules:**
- Verify code does not mutate persistent state
- Enforce timeout limits
- Capture all output for audit trail
- Do not execute code that requires elevated privileges without approval
- Prefer `mutate` for state-changing operations

### Composition Patterns

**Commonly follows:**
- `plan` - Execute planned actions
- `generate` - Execute generated code
- `transform` - Execute transformation scripts

**Commonly precedes:**
- `verify` - Verify execution results
- `detect` - Detect patterns in output
- `audit` - Record execution for audit

**Anti-patterns:**
- Never use execute for persistent state changes (use `mutate`)
- Avoid execute without timeout limits
- Never execute untrusted code without sandboxing

**Workflow references:**
- See `reference/workflow_catalog.yaml#debug_code_change` for execute in testing
- See `reference/workflow_catalog.yaml#digital_twin_sync_loop` for execute in sync loops
