Studio is optimized for desktop. Sign in to save projects, share private or organization links, run against connected repositories, package a CLI command, or create pull requests.
What Studio creates
A new Studio project starts with a small workflow-backed workspace:studio-project
workflow.yaml
rules
main-rule.yaml
codemod
main-codemod.ts
tests
main-codemod
test-1
input.tsx
workflow.yaml is the center of the project. It defines the workflow steps Studio can test and run. The starter workspace usually includes:
- an
ast-grepstep that points torules/main-rule.yaml - a
js-ast-grepstep that points tocodemod/main-codemod.ts - fixture files under
tests/that you can use as local examples
workflow.yaml up to date when you change the files referenced by a workflow step.
Build and validate locally
Use the local workspace to make the codemod correct before you run it on a repository.Choose the language
Pick the source language from the language selector. Studio uses that language for the starter files, AST parsing, ast-grep rules, and JS ast-grep execution.
Edit the workflow step
Open the rule or codemod file you want to work on. Studio uses
workflow.yaml and the open file to decide which step is being tested.Add representative fixtures
Add source files for the cases you care about. Keep them small and specific: one fixture for the common path, then separate fixtures for edge cases.
Inspect the result
Use the source tabs to switch between the current source, rewritten output, and diff. Use the AST panel to inspect syntax nodes, and use the matches or debug panel to understand what the active step did.
Use Codemod AI
Codemod AI can help edit the Studio project, but you still review and apply the changes. Open Codemod AI, describe the focused change you want, and include before/after examples when they clarify the behavior. The assistant can inspect files, propose edits, and run codemod tests against the Studio workspace. When Codemod AI proposes file changes, review them before applying. If the change goes in the wrong direction, revert it and narrow the prompt or add a fixture that captures the missing behavior. Good prompts are specific:Run against a repository
After the local examples look right, use the Results panel to run the selected workflow step against a connected repository.Select a repository
Choose a repository from the Results panel. You must be signed in and have repository access configured.
Choose the step
If the workflow has multiple runnable steps, choose the rule or codemod step you want to run.
Run the search or transform
Click Run. Studio runs the selected step remotely and streams results back into the panel.
Repository runs from Studio are for validation. They do not directly commit changes to the repository.
Save, share, and deploy
Use the project menu to create a new project, save the current project, delete saved projects, or share the current state. Shared Studio links include the project state. Signed-in users can share with public, private, or organization access when those options are available. Anonymous sharing creates a public link that anyone with the link can open. When the codemod is ready to leave Studio, use one of the action bar options:- Run CLI packages the current Studio project and gives you an
npx codemod@latest ...command to run from your terminal. - Create PR packages the current Studio project and opens a pull request creation flow for selected repositories.
CLI
Validate and run codemod workflows from your terminal or CI.
Package Structure
Learn how workflow packages are organized.
Workflow Reference
Read the complete
workflow.yaml reference.JSSG
Write JavaScript and TypeScript codemods with JS ast-grep.
Tips for building better codemods
- Clarity is Key: Try to prompt clear requirements when using Codemod AI. Ensure that the transformation logic is clear for both humans and AI. Well-defined logic leads to more accurate codemods.
-
Follow the MECE Principle: When designing test cases, aim for them to be Mutually Exclusive and Collectively Exhaustive (MECE). This means:
- Mutually Exclusive: Each test case should cover a unique scenario without overlap. Ideally, you only need one clear example with a proper description for each pattern. Break down complex transformations into smaller, more manageable parts.
- Collectively Exhaustive: Together, your test cases should cover all possible scenarios for the codemod.
- Test case 1: Regular function to arrow function
- Test case 2: Function with parameters
- Test case 3: Function with default parameters
- Test case 4: Async function
- Balance Simplicity and Complexity: While it’s possible to create complex transformation logics that support all cases, simpler, more focused codemods are often more maintainable and easier to understand.
Example of a good Codemod AI prompt
Example of a good Codemod AI prompt
Give Codemod AI a focused change and a small before/after example when the behavior might be ambiguous. This prompt generates this codemod:Why this prompt worksThis prompt states one atomic transformation, shows concrete before/after examples, and spells out the minimal extra edits required—exactly what the Clarity is Key and Balance Simplicity and Complexity tips recommend.