Solving the hardest problem in computer science with LLMs

How we use LLMs at Mastra to design clean, intuitive APIs by improving naming, structure, and developer workflow.

Sam BhagwatSam Bhagwat·

Feb 14, 2025

·

3 min read

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.

 1myWorkflow
 2  .step(stepOne)
 3  .then(stepTwo)
 4  .after(stepOne)
 5  .step(stepThree)
 6  .then(stepFour)
 7  .after([stepTwo, stepFour])
 8  .step(stepFive)
 9  .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.

Share:
Sam Bhagwat

Sam Bhagwat is the founder and CEO of Mastra. He co-founded Gatsby, which was used by hundreds of thousands of developers. A Stanford graduate and veteran of web development, he authored 'Principles of Building AI Agents' (2025).

All articles by Sam Bhagwat