We all have been using LLM codegen for a bunch of things, but I wanted to share a niche but incredibly high leverage example for us at Mastra: naming things.
We all know that there are only two hard problems in computer science, cache invalidation and naming things.
Hot take: there may only be one now. Naming things is solved.
———-
Some backstory: Mastra is an open-source Typescript agent framework. When you’re building a framework, you need to do a lot of API design, specifically the nouns and verbs your users use.
Class and function names and parameters need to be immediately intuitive for your users.
Should a variable be a function parameter or part of an options object? If you have a multi-tiered configuration, can you set defaults on a class but override them on a particular invocation? Do you want to be descriptive (messageHistory
) or evocative ( semanticRecall
)?
Left to their own devices even great engineers tend to ship overly verbose API names (eg injectVectorHistorySearch
), create overly large options dictionaries, and overload methods in unintuitive ways.
Your framework starts feeling heavyweight.
Does this matter? Yes, it absolutely matters.
I was the cofounder of Gatsby, and we had way too many APIs. Meanwhile, Vercel and Next.js figured out how to ship minimal, evocative powerful APIs. This was a top 3 reason Next.js won.
The struggle for me and Kyle Mathews (my Gatsby cofounder) was to articulate our taste around APIs in a way that was legible to others, as well as meaningfully review APIs others proposed.
And that was incredibly difficult....until AI.
Now, I can describe the parameters of an API problem to Claude -- on web or in Windsurf locally -- and ask it for help. It can access all the underlying code. It will propose five or six plausible approaches. Usually one or two of them stand out, and then you can chat and iterate and improve them.
Even better, I can do this collaboratively on a screenshare with an engineer, so they can themselves learn the process and begin to develop better taste for APIs in conjunction with Claude.
As an example, our workflow graph API has three main methods, .step()
for branching, .then()
for chaining, and .after()
for merging.
myWorkflow
.step(stepOne)
.then(stepTwo)
.after(stepOne)
.step(stepThree)
.then(stepFour)
.after([stepTwo, stepFour])
.step(stepFive)
.commit()
An example Mastra workflow. See our workflow blog post.
Every time we show it to a developer building with AIs, they immediately nod along. The control flow is apparent and intuitive.