Playbook for coding agents
A complete procedure for coding agents that write Sommatic AI workflows as files. Read the contract, edit with stable node ids and tokens, register the resource, validate, open a pull request and, when allowed, preview and apply.
Coding agents (Claude Code, Codex, Cursor and others) can write and change Sommatic AI workflows the same way a developer
does: as JSON files in a Git repository, reviewed through pull requests. This page is the procedure to give them. It is
written to be followed literally; point your agent to its Markdown version at /en/git-sync/agents.md.
Ground rules
- Git is the source of truth. Change files, never the live resource. Sommatic AI only reads the repository.
- Never push to a deployment branch. Work on
feature/*and open a pull request todevelopment. - Never write physical ids or secrets. Use
@@env.NAME@@,@@ref.<key>@@and@@secret.NAME@@tokens. - Keep
node_idstable. Edit nodes in place; only new nodes get new ids. - Never apply without reading the preview, and never deploy to production before the pull request into its branch is merged.
- Stop and ask a person when something in this page does not hold, instead of working around it.
Before you start
Read, in this order:
- The repository: find every
sommatic.json(ignore those undertemplates/and.github/) and the files inenvironments/. Note which branch each environment reads. - The contract: Packages, Environments and tokens and Resource files.
- The page of every node you will use, under
/en/nodes/<slug>/(Markdown at/en/nodes/<slug>.md). It gives theconfigfields, the ports and the status. Do not use a node whose status is partial or experimental. - Expressions for any value that reads data from earlier nodes.
The schemas to validate against are package.schema.json, environment.schema.json and
resource-header.schema.json, under https://docs.sommatic.ai/schemas/git-sync/.
Change an existing workflow
Create a branch
Branch from development: feature/<short-description>.
Edit the file
Open the workflow file listed in the package’s sommatic.json.
- Change a node by editing its
config,labelorportsindraft_nodes. Keep itsnode_id. - Add a node with a new, unique, descriptive
node_id(for examplenode-notify-owner), itsoperator_slug,operator_version,configandportsfrom the node page, and a position ineditor_state.node_positions. - Connect nodes in
draft_edges:from.node_idandfrom.port(a port of the source node),to.node_id. - Remove a node together with its edges and its entry in
node_positions. - If you rename a node’s
label, update every expression that reads it with$('Label').
Use tokens for anything per installation
- Another resource (for example the workflow called by
workflow.chain):@@ref.<key>@@. - An LLM provider, a credential id, a host or a flag:
@@env.NAME@@, and addNAMEundervariablesin every environment file. - A secret: prefer a node’s credential picker (
connection_idholding@@env.NAME@@). If a secret must live in the config, use@@secret.NAME@@and declareNAMEundersecretsin every environment file, with{ "from": "live" }or{ "from": "credential", "id": "…" }. If you do not know the credential id, stop and ask.
Keep the format
Sorted keys, two-space indentation, trailing newline. Do not add id, created, modified, status,
execution_state, latest_version_id or version_counter. Keep the sommatic header unchanged.
Validate
Validate every manifest, resource file and environment file against the schemas, and check that each header key equals its manifest key and that every environment file declares an id for every key. The validator on Branches and CI does all of this.
Open a pull request
Push the branch and open a pull request to development. In the description, list the keys you changed, the nodes
added, removed or changed, and any variable or secret that has to be added to an environment file.
Add a new workflow
A file alone cannot create a workflow: apply only updates resources that already exist in each installation.
Get the ids
Ask the owner of each installation to create the workflow in Sommatic AI and give you its id there. Do not invent ids.
Write the file
Start from an existing workflow file or from an Export for Git… of the new workflow. Set the header
{ "kind": "workflow", "key": "<package>.<slug>", "schema_version": "1.0" } and give the file a path under the
package, such as workflows/<slug>.json.
Register it
Add { "key": "<key>", "path": "workflows/<slug>.json" } to resources.workflows in sommatic.json, and
"<key>": "<id>" to resources in every environment file, each with the id of its own installation.
Validate and open the pull request
Same as above.
Deploy (only when you are allowed to)
Deploying is a separate permission. Do it only when the person you work for asks, and only after the pull request into the installation’s branch is merged.
Preview
curl -s -X POST "$SOMMATIC_API/platform-infrastructure/git-sync/preview" \
-H "Authorization: Bearer $SOMMATIC_TOKEN" \
-H 'Content-Type: application/json' \
-d '{ "repository_id": "<repository_id>", "path": "<package path>", "include_content": false }'Check every item
Stop and report if any item has a non-empty unresolved, has exists: false or carries an error. Confirm that
changes matches what the pull request intended: the nodes added, removed and changed, and the fields.
Apply that commit
curl -s -X POST "$SOMMATIC_API/platform-infrastructure/git-sync/apply" \
-H "Authorization: Bearer $SOMMATIC_TOKEN" \
-H 'Content-Type: application/json' \
-d '{ "repository_id": "<repository_id>", "path": "<package path>", "expected_commit": "<commit from the preview>", "publish": true, "description": "Pull request #<number>" }'If apply says the branch moved, preview again and review the new commit. Never retry with an older commit.
Report
Report the commit, the keys applied, unchanged, skipped and failed, the reason of any failure and each published
version.
Stop conditions
Stop and ask a person when:
- a preview item has
unresolvedtokens orexists: false; - a resource you need to change is
unlinked_herein the installation; - you would need a physical id or a secret value to finish;
- export left
@@secret.REPLACE_ME@@and you do not know the secret’s name or source; - the only way forward is a direct push, an apply of a commit that is not the head of the branch, or a production deploy before the merge.