Show HN: Codegen – OSS Python Library for Advanced Code Manipulation(docs.codegen.com) Hey HN! We've just open-sourced Codegen (https://github.com/codegen-sh/codegen-sdk), a Python library for manipulating Python + JS/React codebases. Codegen was engineered backwards from real-world, large-scale codebase analysis + refactors we performed on multi-million-line enterprise codebases. It provides a scriptable interface to a powerful, multi-lingual language server built on Tree-sitter. We realized that many code transformation tasks that impact large teams - refactors, enforcing patterns, analyzing control flow - are fundamentally programmatic operations. Yet existing tools like LibCST and Jscodeshift often require you to think in terms of ASTs and parser internals rather than the high-level changes you want to make. Therefore, we built Codegen to match how developers actually think about code changes:
Codegen handles the edge cases automatically - updating imports, preserving dependencies, maintaining references, and resolving naming conflicts. You focus on intent, we handle the details.Under the hood, Codegen performs static analysis to build a rich graph representation of your code. This enables: - Versatile and comprehensive operations - Built-in visualization capabilities - Blazing fast execution of large-scale refactors We've seen a wide variety of advanced code manipulation programs emerge, including: - Mining codebases for LLM pre-training data - Analyzing security vulnerabilities - Large-scale API migrations - Enforcing code patterns We're excited to share this with the community and look forward to your feedback. Give it a spin and let us know what you think!
Docs: https://docs.codegen.com
GitHub: https://github.com/codegen-sh/codegen-sdk
Community: https://community.codegen.comLet us know if you have any questions or interesting use cases you'd like to explore. |