Published: October 24, 2025
2
2
13

Behind the elegant and seemingly simple looking 'use workflow' and 'use step' directives of the new workflow development kit from @vercel lies a bunch of compiler engineering. I was curious and decided to dive deeper into the open source code. Buckle up and read this post if you

Image in tweet by Karthik Kalyan

The Compilation Plugin Let's start with the compilation process. The workflow development kit uses SWC Plugin with a visitor pattern for source code transformation. Before I go further, what is SWC? SWC expands to Speedy Web Compiler which is primarily used for transpiling,

Image in tweet by Karthik Kalyan

So what does the compiler plugin do with these directives? The compiler plugin operates in 3 modes to compile and transform the code for 3 separate scenarios: 1. Step mode: In this mode, step directives are removed, the function body is kept intact for actual execution, and the

Image in tweet by Karthik Kalyan

But, lets take a step back. Why directives and why do all this complex compilation? Developer Experience! While its a debated topic at the moment, building workflows with durable steps without needing to learn any new language semantics and by simply including a 'use workflow'

Image in tweet by Karthik Kalyan

The World Interface Now, lets take a step back and understand how the workflow code we write does not know or care about WHERE the data is stored and HOW queues work. This is where the "World" interface comes into the picture. The world interface defines the different

Image in tweet by Karthik Kalyan

The runtime uses a singleton pattern to inject a world as a dependency. If the workflow code is deployed to Vercel, it uses the target world as vercel and vercel automatically brings it's set of components behind the scenes. If you are running it locally, it uses the 'embedded'

Image in tweet by Karthik Kalyan

Sleep Some interesting observations with the implementation of the Sleep() function. await sleep("3d"); What's interesting here is that, the sleep function itself is a durable step with a 'use step' directive. But, one minor issue can be observed here: There is

Image in tweet by Karthik Kalyan

Additional Notes 1. Directive typos The SWC plugin handles typos in directives with an edit distance <= 1 - meaning, if you write 'use setp' instead of 'use step', it will through a compilation error asking if you meant 'use step'. It can handles substitution ('use setp'),

Finally, I thoroughly enjoyed diving deeper into the open source code base of this workflow development kit. Kudos to the @vercel team - @rauchg, @cramforce and all for shipping this. If my understanding of any of this is factually incorrect, feel free to correct me in the

@karthikkalyan90 @vercel Great thread! Appreciate the context. Hope you will get a chance to really address this https://x.com/kamikaz1_k/statu...

Share this thread

Read on Twitter

View original thread

Navigate thread

1/10