---
title: "Prepare your actual application"
description: "Turn a discovered candidate into an executable, reviewed test bundle."
canonical: "https://agenttwin.si/docs/preparation/"
---

# Prepare your actual application

Turn a discovered candidate into an executable, reviewed test bundle.


## Discovery is the starting point

Run `npx agenttwin init` inside your application repository. Review `.agenttwin/inventory.json` and the workflow candidates. An entrypoint or dependency found in source is a candidate, not proof of provider access or a runnable test.

Choose one narrow workflow with observable effects. Identify its built Node entrypoint, required inputs, every service operation, synthetic starting records and expected outputs. Other coding agents can use `.agenttwin/AGENT-TASK.md`; discovery does not automatically supply a correct executable test.

## Build and configure the entrypoint

The runtime does not transpile TypeScript or install application dependencies. Bundle them first and list the required built files. `command` is an argv array beginning with `node`. Application file paths resolve relative to the world specification.

Configure test clients with generated `AGENTTWIN_<SERVICE>_URL` and `AGENTTWIN_<SERVICE>_TOKEN` values. A production SDK requires a supported base-URL override and supported operations; merely replacing a token is insufficient. Use synthetic IDs and avoid copying production credentials into the bundle.

## A preparation contract

Save this as `preparation.json` beside your built `workflow.mjs`. Replace both discovery IDs with the actual IDs in your inventory. This example prepares a Slack notification; it is not a complete Slack replica.

```json
{
  "schema": "agenttwin/preparation-v1",
  "workflowId": "YOUR_DISCOVERED_WORKFLOW_ID",
  "world": {
    "schema": "agenttwin/world-v1",
    "name": "notification",
    "files": ["workflow.mjs"],
    "command": ["node", "workflow.mjs"],
    "timeoutSeconds": 20,
    "services": [{
      "name": "slack",
      "adapter": "slack",
      "collections": [
        {"path": "/messages", "seed": []},
        {"path": "/channels", "seed": [{"id": "C_TEST", "name": "test"}]}
      ]
    }],
    "assertions": [{"service": "slack", "path": "/messages", "count": 1}]
  },
  "mappings": [{
    "toolId": "YOUR_DISCOVERED_SLACK_TOOL_ID",
    "service": "slack",
    "contract": "slack",
    "operations": ["chat.postMessage"],
    "reviewed": true
  }]
}
```

Your application must send a message to the seeded channel using the generated connection information. The assertion checks one recorded message; add stronger observable checks appropriate to your workflow. Include every recorded candidate operation in reviewed mappings. Preparation rejects missing or unsupported mappings, but cannot establish that static discovery found every behavior in arbitrary source.

## Prepare, review, execute

```sh
npx agenttwin prepare --file preparation.json --out .agenttwin/prepared/notification
npx agenttwin contracts --file .agenttwin/prepared/notification/agenttwin.world.json --json
npx agenttwin run --file .agenttwin/prepared/notification/agenttwin.world.json --json
```

Preparation copies unchanged listed source and writes the world spec, a SHA-256 manifest and `agenttwin.bundle.json`. It does not execute the application. Review the upload list, bundled source, fixtures and checks before running or uploading.

Local execution supports HTTP collections and bounded Slack operations. PostgreSQL and Redis need explicit cloud execution. In Workflows, select the bundle and review its upload before submitting a cloud job. See [execution boundaries](/docs/safety/).

## Retest the right files

For a one-shot prepared bundle, changing your original source does not update a previously copied bundle: rebuild and prepare again. For a reusable world, every run restages the files listed by that world's specification and resets its baseline. Confirm which files the spec references before patching.

Do not make a failing check pass by weakening the outcome or removing the fault. Inspect evidence, patch source and compare receipts under unchanged test conditions. [Understand the receipt](/docs/evidence/) before approving a repair.
