Codegen is an IDE for rapidly building, running, and merging large code transformations.

Codegen enables developers to programmatically manipulate their codebase via metaprogramming, like the following:

# grab codebase content
file = codebase.files[0] # or .get_file("test.py")
function = codebase.functions[0] # or .get_symbol("my_func")

# print logs
print(f'# of files: {len(codebase.files)}')
print(f'# of functions: {len(codebase.functions)}')

# make edits
file.edit('🌈' + file.content) # edit contents
function.rename('new_name') # rename
function.set_docstring('new docstring') # set docstring

# ... etc.

Level Up your Codebase

Features

Why Codegen

Traditional code transformation tools often require deep understanding of abstract syntax trees (ASTs) and can be complex to use.

Codegen’s GraphSitter API addresses these challenges by providing:

  1. Intuitive API: GraphSitter is designed to be easily understood and used, even by developers who aren’t experts in code parsing or ASTs.

  2. Powerful Abstractions: Our library provides high-level abstractions that encapsulate common code transformation patterns, reducing the amount of boilerplate code you need to write.

  3. Language Agnostic: While currently supporting Python, TypeScript, JavaScript, and React, GraphSitter’s design allows for easy extension to other languages in the future.

  4. Performance: GraphSitter is optimized for performance, allowing for quick transformations even on large codebases.

  5. Contextual Awareness: Unlike simple text-based search and replace tools, GraphSitter understands the structure of your code, allowing for more precise and reliable transformations.

By using GraphSitter, you can focus on defining what changes you want to make to your code, rather than getting bogged down in the details of how to parse and modify ASTs.

Was this page helpful?