Generated banner for AWS Step Functions
Generated logo for AWS Step Functions

AWS Step Functions

AWS LabsOfficialPublished by AWS Labs

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • No issues found

From the author

Build workflows with AWS Step Functions state machines using the JSONata query language. Covers Amazon States Language (ASL) structure, state types, variables, data transformation, error handling, AWS service integration, and migrating from the JSONPath to the JSONata query language.
— the description by AWS Labs

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides comprehensive documentation and patterns for defining workflows in AWS Step Functions. It focuses on the Amazon States Language (ASL) and the use of JSONata for data transformation and logic. The skill covers the eight core state types, error handling, service integrations, and best practices for migrating from legacy JSONPath to JSONata. It also includes architectural patterns such as the Saga pattern, polling loops, and semaphore locks to help developers design robust distributed applications.

What it does

  • Explains ASL structure and the eight available state types.
  • Provides syntax guidance for JSONata expressions in state machines.
  • Details error handling strategies using Retry and Catch blocks.
  • Outlines patterns for AWS service integrations like Lambda, DynamoDB, and SQS.
  • Offers architectural templates for common workflow challenges.
  • Provides instructions for migrating existing state machines from JSONPath to JSONata.

When to use it

  • When designing distributed applications or orchestrating microservices on AWS.
  • When building data or machine learning pipelines that require automated processes.
  • When implementing complex logic like retries, error handling, or branching in cloud workflows.
  • When transitioning state machine definitions to use JSONata for data transformation.

Advantages

  • Centralized reference for ASL syntax and JSONata expressions.
  • Includes ready-to-use architectural patterns for common distributed system problems.
  • Clear guidance on state input/output management and variable assignment.
  • Provides comparative analysis between Standard and Express workflow types.

Usage examples

“How do I implement a retry policy in a Task state?”
The agent provides the syntax for the Retry field, explaining how to define error codes, interval seconds, and max attempts within an ASL Task state.
“Show me how to use JSONata to transform output in a Pass state.”
The agent provides a code example demonstrating the use of the Output field with JSONata expressions to format data dynamically.
“What is the difference between Standard and Express workflows?”
The agent returns a comparison table detailing differences in execution duration, throughput, pricing, and history retention.
“How do I migrate my state machine from JSONPath to JSONata?”
The agent explains the replacement of JSONPath fields like InputPath and ResultPath with the new Arguments and Output fields, and provides migration steps.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/awslabs/aws-step-functions/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip aws-step-functions.zip -d .agents/skills

Documentation by AWS Labs

AWS Step Functions

Overview

AWS Step Functions uses Amazon States Language (ASL) to define state machines as JSON. With AWS Step Functions, you can create workflows, also called State machines, to build distributed applications, automate processes, orchestrate microservices, and create data and machine learning pipelines.

This skill provides comprehensive guidance for writing state machines in ASL, covering:

  • ASL structure and JSONata expression syntax

  • Details on the eight available workflow states

  • The $states reserved variable

  • Workflow variables with Assign

  • Error handling

  • AWS Service integration patterns

  • Example code for data transformation and architecture

  • Validation and testing of state machines

  • How to migrate from JSONPath to JSONata

When to Load Reference Files

Load the appropriate reference file based on what the user is working on:

  • ASL structure, state types, Task, Pass, Choice, Wait, Succeed, Fail, Parallel, Map → see references/asl-state-types.md

  • Error handling, troubleshooting, Retry, Catch, fallback, error codes, States.Timeout, States.ALL → see references/error-handling.md

  • Service integrations, Lambda invoke, DynamoDB, SNS, SQS, SDK integrations, Resource ARN, sync, async → see references/service-integrations.md

  • Migrating from JSONPath to JSONata, migration, JSONPath to JSONata, InputPath, Parameters, ResultSelector, ResultPath, OutputPath, intrinsic functions, Iterator, payload template → see references/migrating-from-jsonpath-to-jsonata.md

  • Validation, linting, testing, TestState, test state, mock, mocking, unit test, inspection level, DEBUG, TRACE, validate state, test in isolation → see references/validation-and-testing.md

  • Architecture patterns, examples, polling, saga, compensation, scatter-gather, semaphore, lock, human-in-the-loop, escalation, Express to Standard → see references/architecture-patterns.md

  • Data transformation, JSONata expressions, filtering, aggregation, string operations, $reduce, $lookup, $toMillis, $partition, $parse, $hash, $uuid → see references/transforming-data.md

  • State input/output, $states, Assign, Output, Arguments, variable scope, variable limits, evaluation order, passing data between states → see references/processing-state-inputs-and-outputs.md

  • Deployment, SAM, CloudFormation, IaC, DefinitionSubstitutions, X-Ray tracing, logging → see the aws-serverless-deployment skill or deploy-on-aws plugin

Quick Reference

Standard vs Express Workflows
StandardExpress
Max duration1 year5 minutes
Execution semanticsExactly-onceAt-least-once (async) / At-most-once (sync)
Execution historyRetained 90 days, queryable via APICloudWatch Logs only
Max throughput2,000 exec/sec100,000 exec/sec
Pricing modelPer state transitionPer execution count + duration
.sync / .waitForTaskTokenSupportedNot supported
Best forAuditable, non-idempotent operationsHigh-volume, idempotent event processing

Choose Standard for: payment processing, order fulfillment, compliance workflows, anything that must never execute twice.

Choose Express for: IoT data ingestion, streaming transformations, mobile backends, high-throughput short-lived processing.

Setting the State Machine Query Language

JSONata is the modern, preferred way to reference and transform data in ASL. It replaces the five JSONPath I/O fields (InputPath, Parameters, ResultSelector, ResultPath, OutputPath) with just two: Arguments (inputs) and Output.

Enable at the top level to apply to all states:

{ "QueryLanguage": "JSONata", "StartAt": "...", "States": {...} }

Or per-state to migrate from JSONPath incrementally:

{ "Type": "Task", "QueryLanguage": "JSONata", ... }

JSONPath is still supported and is the default if QueryLanguage is omitted — existing state machines do not need to be migrated.

Best Practices

  • Set "QueryLanguage": "JSONata" at the top level for new state machines unless the user wants to use JSONPath

  • Keep Output minimal — only include what the state immediately after the current state needs

  • Use Assign to store variables needed in later states instead of threading it through Output

  • Use $states.input to reference original state input

  • Remember: Assign and Output are evaluated in parallel — variable assignments in Assign are NOT available in Output of the same state

  • All JSONata expressions must produce a defined value — $data.nonExistentField throws States.QueryEvaluationError

  • Use $states.context.Execution.Input to access the original workflow input from any state

  • Save state machine definitions with .asl.json extension when working outside the console

  • Prefer the optimized Lambda integration (arn:aws:states:::lambda:invoke) over the SDK integration

Troubleshooting

Common Errors
  • States.QueryEvaluationError — JSONata expression failed. Check for type errors, undefined fields, or out-of-range values.

  • Mixing JSONPath fields with JSONata fields in the same state.

  • Using $ or $$ at the top level of a JSONata expression — use $states.input instead.

  • Forgetting {% %} delimiters around JSONata expressions — the string will be treated as a literal.

  • Assigning variables in Assign and expecting them in Output of the same state — new values only take effect in the next state.

  • Reference references/validation-and-testing.md and references/error-handling.md for detailed troubleshooting information.

Resources

Files

references/migrating-from-jsonpath-to-jsonata.md

Migrating from JSONPath to JSONata

Complete conversion guide for migrating existing JSONPath state machines to JSONata. Covers fields, states, intrinsic functions, common pitfalls, and the end-to-end conversion workflow.

JSONPath → JSONata Quick Reference

JSONPathJSONata
InputPathNot needed — use $states.input directly in Arguments
ParametersArguments
ResultSelectorOutput (reference $states.result)
ResultPathAssign (preferred) or Output
OutputPathOutput (return only what you need)
TimeoutSecondsPathTimeoutSeconds with {% %}
HeartbeatSecondsPathHeartbeatSeconds with {% %}
ItemsPathItems with {% %}
"key.$": "$.field""key": "{% $states.input.field %}"
$ or $.field (state input)$states.input or $states.input.field
$$ (context object)$states.context
$$.Execution.Input$states.context.Execution.Input
$$.Task.Token$states.context.Task.Token
$$.Map.Item.Value$states.context.Map.Item.Value
$variable (workflow var)$variable (unchanged)

Converting Each State Type

Task State

Before (JSONPath):

"ProcessOrder": {
  "Type": "Task",
  "Resource": "arn:aws:states:::lambda:invoke",
  "InputPath": "$.order",
  "Parameters": {
    "FunctionName": "arn:aws:lambda:us-east-1:123456789012:function:Process:$LATEST",
    "Payload": { "id.$": "$.orderId", "customer.$": "$.customerName" }
  },
  "ResultSelector": { "processedId.$": "$.Payload.id", "status.$": "$.Payload.status" },
  "ResultPath": "$.processingResult",
  "OutputPath": "$.processingResult",
  "Next": "Ship"
}

After (JSONata):

"ProcessOrder": {
  "Type": "Task",
  "Resource": "arn:aws:states:::lambda:invoke",
  "Arguments": {
    "FunctionName": "arn:aws:lambda:us-east-1:123456789012:function:Process:$LATEST",
    "Payload": { "id": "{% $states.input.order.orderId %}", "customer": "{% $states.input.order.customerName %}" }
  },
  "Output": { "processedId": "{% $states.result.Payload.id %}", "status": "{% $states.result.Payload.status %}" },
  "Next": "Ship"
}
Pass State

Before (JSONPath):

"InjectDefaults": {
  "Type": "Pass",
  "Result": { "region": "us-east-1" },
  "ResultPath": "$.config",
  "Next": "Go"
}

After (JSONata):

"InjectDefaults": {
  "Type": "Pass",
  "Assign": { "region": "us-east-1" },
  "Next": "Go"
}
Choice State

JSONPath uses Variable + typed operators. JSONata uses a single Condition expression.

Before (JSONPath):

"Choices": [
  { "Variable": "$.status", "StringEquals": "approved", "Next": "Approved" },
  { "And": [
    { "Variable": "$.priority", "StringEquals": "high" },
    { "Variable": "$.age", "NumericLessThanEquals": 30 }
  ], "Next": "FastTrack" },
  { "Not": { "Variable": "$.email", "IsPresent": true }, "Next": "RequestEmail" }
]

After (JSONata):

"Choices": [
  { "Condition": "{% $states.input.status = 'approved' %}", "Next": "Approved" },
  { "Condition": "{% $states.input.priority = 'high' and $states.input.age <= 30 %}", "Next": "FastTrack" },
  { "Condition": "{% $not($exists($states.input.email)) %}", "Next": "RequestEmail" }
]
Choice Operator Mapping
JSONPath OperatorJSONata
StringEquals / StringEqualsPath= 'value' / = $states.input.other
NumericGreaterThan / NumericLessThanEquals> value / <= value
BooleanEquals= true / = false
TimestampGreaterThan$toMillis(field) > $toMillis('ISO-timestamp')
IsPresent: true / false$exists(field) / $not($exists(field))
IsNull: truefield = null
IsNumeric / IsString / IsBoolean$type(field) = 'number' / 'string' / 'boolean'
StringMatches (wildcards)$contains(field, /regex/)
And / Or / Notand / or / $not()
Wait State

Before (JSONPath):

{ "Type": "Wait", "TimestampPath": "$.deliveryDate", "Next": "Check" }

After (JSONata):

{ "Type": "Wait", "Timestamp": "{% $states.input.deliveryDate %}", "Next": "Check" }
Map State
JSONPathJSONata
ItemsPathItems (fold InputPath into expression)
Parameters (with $$.Map.*)ItemSelector (with $states.context.Map.*)
IteratorItemProcessor (add ProcessorConfig)
ResultSelector inside iteratorOutput inside processor states
ResultPath on MapAssign

After (JSONata):

"ProcessItems": {
  "Type": "Map",
  "Items": "{% $states.input.orderData.items %}",
  "ItemSelector": {
    "item": "{% $states.context.Map.Item.Value %}",
    "index": "{% $states.context.Map.Item.Index %}"
  },
  "MaxConcurrency": 5,
  "ItemProcessor": {
    "ProcessorConfig": { "Mode": "INLINE" },
    "StartAt": "Process",
    "States": {
      "Process": {
        "Type": "Task",
        "Resource": "arn:aws:states:::lambda:invoke",
        "Arguments": { "FunctionName": "arn:aws:lambda:us-east-1:123456789012:function:Process:$LATEST", "Payload": "{% $states.input %}" },
        "Output": "{% $states.result.Payload %}",
        "End": true
      }
    }
  },
  "Assign": { "processedItems": "{% $states.result %}" },
  "Next": "Done"
}

Converting Intrinsic Functions

JSONPath IntrinsicJSONata Equivalent
States.Format('Order {}', $.id)'Order ' & $states.input.id
States.StringToJson($.str)$parse($states.input.str)
States.JsonToString($.obj)$string($states.input.obj)
States.StringSplit($.str, ',')$split($states.input.str, ',')
States.Array($.a, $.b)[$states.input.a, $states.input.b]
States.ArrayPartition($.arr, 2)$partition($states.input.arr, 2)
States.ArrayContains($.arr, $.v)$states.input.v in $states.input.arr
States.ArrayRange(0, 10, 2)$range(0, 10, 2)
States.ArrayGetItem($.arr, 0)$states.input.arr[0]
States.ArrayLength($.arr)$count($states.input.arr)
States.ArrayUnique($.arr)$distinct($states.input.arr)
States.Base64Encode($.str)$base64encode($states.input.str)
States.Base64Decode($.str)$base64decode($states.input.str)
States.Hash($.data, 'SHA-256')$hash($states.input.data, 'SHA-256')
States.JsonMerge($.a, $.b)$merge([$states.input.a, $states.input.b])
States.MathRandom()$random()
States.MathAdd($.a, $.b)$states.input.a + $states.input.b
States.UUID()$uuid()

Converting Catch Blocks

JSONPath Catch uses ResultPath. JSONata Catch uses Assign and Output with $states.errorOutput.

Before (JSONPath):

"Catch": [{ "ErrorEquals": ["States.ALL"], "ResultPath": "$.error", "Next": "HandleError" }]

After (JSONata):

"Catch": [{
  "ErrorEquals": ["States.ALL"],
  "Assign": { "errorInfo": "{% $states.errorOutput %}" },
  "Output": "{% $states.input %}",
  "Next": "HandleError"
}]

Retry syntax is identical between JSONPath and JSONata — no conversion needed.


Conversion Pitfalls and How to Avoid Them

1. Do not mix JSONPath and JSONata fields in the same state

Invalid combinations: Arguments + InputPath, Output + ResultSelector, Condition + Variable. Remove all JSONPath fields from converted states.

2. You must remove .$ suffixes
❌  "orderId.$": "{% $states.input.orderId %}"
✓  "orderId": "{% $states.input.orderId %}"
3. Use $states instead of $ or $$.
❌  "{% $.orderId %}"        ❌  "{% $$.Task.Token %}"
✓  "{% $states.input.orderId %}"   ✓  "{% $states.context.Task.Token %}"

Note: $ is valid inside nested filter expressions (e.g., $states.input.items[$.price > 10]).

4. Do not use double quotes inside JSONata expressions
❌  "{% $states.input.status = "active" %}"
✓  "{% $states.input.status = 'active' %}"
5. Do not attempt to access the output of Assign or Output in the same state where they are assigned.

Assign and Output evaluate in parallel — new variable values are not available until the next state.

❌  "Assign": { "total": "{% $states.result.Payload.total %}" },
    "Output": { "total": "{% $total %}" }
✓  "Assign": { "total": "{% $states.result.Payload.total %}" },
    "Output": { "total": "{% $states.result.Payload.total %}" }
6. Use defensive coding to prevent undefined errors in JSONata

JSONPath silently returns null. JSONata throws States.QueryEvaluationError:

❌  "{% $states.input.customer.middleName %}"
✓  "{% $exists($states.input.customer.middleName) ? $states.input.customer.middleName : '' %}"
7. Use defensive coding to prevent invalid filter results

JSONata returns a single object (not a 1-element array) when exactly one item matches a filter, and undefined when nothing matches. Both break Map state Items and functions like $count:

❌  "Items": "{% $states.input.orders[status = 'pending'] %}"
✓  "Items": "{% ( $f := $states.input.orders[status = 'pending']; $type($f) = 'array' ? $f : $exists($f) ? [$f] : [] ) %}"
8. Iterator → ItemProcessor rename

Iterator was renamed to ItemProcessor and requires ProcessorConfig:

❌  "Iterator": { "StartAt": "...", "States": {...} }
✓  "ItemProcessor": { "ProcessorConfig": { "Mode": "INLINE" }, "StartAt": "...", "States": {...} }

Conversion Workflow

For each state being converted, apply these steps in order:

  1. Add "QueryLanguage": "JSONata" to the state

  2. Parameters → Arguments: remove .$ suffixes from all keys, wrap values in {% %}, replace $ with $states.input and $$ with $states.context

  3. Convert ResultPath based on its value:

    • Absent or "$" → no action needed (default behavior is replaced by Output)

    • null → add "Output": "{% $states.input %}"

    • "$.field" → add "Assign": { "field": "{% $states.result %}" } and "Output": "{% $states.input %}"

  4. ResultSelector → fold selection logic into Output (reference $states.result)

  5. OutputPath → fold into Output (return only what you need)

  6. Reminder: If the state has ResultSelector + ResultPath + OutputPath, collapse all three into a single Output field

  7. Remove all five JSONPath I/O fields: InputPath, Parameters, ResultSelector, ResultPath, OutputPath

  8. Convert *Path fields to base field + {% %} expression (TimeoutSecondsPath → TimeoutSeconds, HeartbeatSecondsPath → HeartbeatSeconds, ItemsPath → Items)

  9. Replace States.* intrinsic functions with JSONata equivalents (see Converting Intrinsic Functions table)

  10. Choice states: replace Variable + comparison operators with a single Condition expression

  11. Map states: Iterator → ItemProcessor with ProcessorConfig, ItemsPath → Items, Parameters with $$.Map.* → ItemSelector with $states.context.Map.*

  12. Catch blocks: replace ResultPath with Assign + Output using $states.errorOutput

  13. Pass states: replace Result with Output or Assign

  14. Where multiple consecutive states used ResultPath to thread data through the payload, refactor to use Assign variables instead — downstream states reference $variableName directly

  15. Validate the converted state using the TestState API

  16. Repeat for all states, then promote "QueryLanguage": "JSONata" to the top level and remove per-state declarations

Requirements and compatibility

Written for: Claude Code

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Claude Code frontmatter

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
AWS Labs
Publisher
AWS Labs (Official)
Source
awslabs/agent-plugins · plugins/aws-serverless/skills/aws-step-functions · commit fbefb37
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • NOTICE (added by AutoGineer from NOTICE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by AWS Labs.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aws-step-functions.zip