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://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/processing-state-inputs-and-outputs.md

Processing State Inputs and Outputs

State Fields Quick Reference

FieldPurposeAvailable In
TypeState type identifierTask, Parallel, Map, Pass, Wait, Choice, Succeed, Fail
CommentHuman-readable descriptionTask, Parallel, Map, Pass, Wait, Choice, Succeed, Fail
OutputTransform state outputTask, Parallel, Map, Pass, Wait, Choice, Succeed
AssignStore workflow variablesTask, Parallel, Map, Pass, Wait, Choice
Next / EndTransition controlTask, Parallel, Map, Pass, Wait
ArgumentsInput to task/branchesTask, Parallel
Retry & CatchError handlingTask, Parallel, Map
Itemsa JSON array, a JSON object, or a JSONata expressionMap
ItemSelectorReshape each item before processingMap
ConditionBoolean branchingChoice (inside rules)
Error & CauseError name and description (accept JSONata)Fail

The $states Reserved Variable

Step Functions provides a reserved $states variable in every JSONata state:

$states = {
  "input":       // Original input to the state
  "result":      // Task/Parallel/Map result (if successful)
  "errorOutput": // Error Output (only available in Catch)
  "context":     // Context object (execution metadata)
}
Context Object Fields
PathTypeDescription
$states.context.Execution.IdStringExecution ARN
$states.context.Execution.InputObjectOriginal workflow input
$states.context.Execution.NameStringExecution name
$states.context.Execution.RoleArnStringIAM execution role
$states.context.Execution.StartTimeString (ISO 8601)When execution started
$states.context.Execution.RedriveCountNumberNumber of times execution was redriven
$states.context.Execution.RedriveTimeString (ISO 8601)When execution was last redriven
$states.context.State.EnteredTimeString (ISO 8601)When current state was entered
$states.context.State.NameStringCurrent state name
$states.context.State.RetryCountNumberNumber of retries attempted
$states.context.StateMachine.IdStringState machine ARN
$states.context.StateMachine.NameStringState machine name
$states.context.Task.TokenStringTask token (only in .waitForTaskToken states)
$states.context.Map.Item.IndexNumberIndex number for the array item that is being currently processed
$states.context.Map.Item.ValueanyCurrent item being processed
$states.context.Map.Item.KeyStringProperty name when iterating over a JSON object (not valid for arrays)
$states.context.Map.Item.SourceStringItem source: STATE_DATA for state input, S3://bucket-name for S3 LIST_OBJECTS_V2 with NONE transformation, or S3://bucket-name/object-key for all other S3 input types

Workflow Variables with Assign

Variables let you store data in one state and reference it in any subsequent state without threading data through Output/Input chains.

Declaring Variables
"StoreData": {
  "Type": "Pass",
  "Assign": {
    "productName": "product1",
    "count": 42,
    "available": true,
    "config": "{% $states.input.configuration %}"
  },
  "Next": "UseData"
}
Referencing Variables

Prepend the variable name with $:

"Arguments": {
  "product": "{% $productName %}",
  "quantity": "{% $count %}"
}
Assigning from Task Results
"FetchPrice": {
  "Type": "Task",
  "Resource": "arn:aws:states:::lambda:invoke",
  "Arguments": {
    "FunctionName": "arn:aws:lambda:us-east-1:123456789012:function:GetPrice:$LATEST",
    "Payload": {
      "product": "{% $states.input.product %}"
    }
  },
  "Assign": {
    "currentPrice": "{% $states.result.Payload.price %}"
  },
  "Output": "{% $states.result.Payload %}",
  "Next": "CheckPrice"
}
Assign in Choice Rules and Catch

Choice Rules and Catch blocks can each have their own Assign:

"CheckValue": {
  "Type": "Choice",
  "Choices": [
    {
      "Condition": "{% $states.input.value > 100 %}",
      "Assign": {
        "tier": "premium"
      },
      "Next": "PremiumPath"
    }
  ],
  "Default": "StandardPath",
  "Assign": {
    "tier": "standard"
  }
}

If a Choice Rule matches, its Assign is used. If no rule matches, the state-level Assign is used.


Variable Evaluation Order

All expressions in Assign and Output are evaluated in parallel using variable values as they were on state entry. New values only take effect in the next state.

"SwapExample": {
  "Type": "Pass",
  "Assign": {
    "x": "{% $y %}",
    "y": "{% $x %}"
  },
  "Next": "AfterSwap"
}

If $x = 3 and $y = 6 on entry, after this state: $x = 6, $y = 3. This works because all expressions are evaluated first, then assignments are made.

You cannot assign to a sub-path of a variable:

  • Valid: "Assign": {"x": 42}

  • Invalid: "Assign": {"x.y": 42} or "Assign": {"x[2]": 42}


Variable Scope

Variables exist in a state-machine-local scope:

  • Outer scope: All states in the top-level States field.

  • Inner scope: States inside a Parallel branch or Map iteration.

Scope Rules
  1. Inner scopes can READ variables from outer scopes.

  2. Inner scopes CANNOT ASSIGN to variables that exist in an outer scope.

  3. Variable names must be unique across outer and inner scopes (no shadowing).

  4. Variables in different Parallel branches or Map iterations are isolated from each other.

  5. When a Parallel branch or Map iteration completes, its variables go out of scope.

  6. Exception: Distributed Map states cannot reference variables in outer scopes.

Passing Data Out of Inner Scopes

Use Output on terminal states within branches/iterations to return data to the outer scope:

"ParallelWork": {
  "Type": "Parallel",
  "Branches": [
    {
      "StartAt": "BranchA",
      "States": {
        "BranchA": {
          "Type": "Task",
          "Resource": "...",
          "Output": "{% $states.result.Payload %}",
          "End": true
        }
      }
    }
  ],
  "Assign": {
    "branchAResult": "{% $states.result[0] %}"
  },
  "Next": "Continue"
}
Catch Assign and Outer Scope

A Catch block in a Parallel or Map state can assign values to variables in the outer scope (the scope where the Parallel/Map state exists):

"Catch": [
  {
    "ErrorEquals": ["States.ALL"],
    "Assign": {
      "errorOccurred": true,
      "errorDetails": "{% $states.errorOutput %}"
    },
    "Next": "HandleError"
  }
]

Arguments and Output Fields

Arguments

Provides input to Task and Parallel states:

"Arguments": {
  "staticField": "hello",
  "dynamicField": "{% $states.input.name %}",
  "computed": "{% $count($states.input.items) %}"
}
Output

Transforms the state output:

"Output": {
  "customerId": "{% $states.input.id %}",
  "result": "{% $states.result.Payload %}",
  "processedAt": "{% $now() %}"
}

If Output is not provided:

  • Task, Parallel, Map: state output = the result

  • All other states: state output = the state input


Variable Limits

LimitValue
Max size of a single variable256 KiB
Max combined size in a single Assign256 KiB
Max total stored variables per execution10 MiB
Max variable name length80 Unicode characters

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 or AWS Labs.

Download ZIP

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