Skip to content

Commit 834f210

Browse files
jayhackcodegen-bot
and
codegen-bot
authored
docs: tightens up many docs (#109)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed - [ ] I have read and agree to the [Contributor License Agreement](../CLA.md) --------- Co-authored-by: codegen-bot <[email protected]>
1 parent 249a85a commit 834f210

File tree

8 files changed

+56
-103
lines changed

8 files changed

+56
-103
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,34 @@ for function in codebase.functions:
2424

2525
Write code that transforms code. Codegen combines the parsing power of [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) with the graph algorithms of [rustworkx](https://github.com/Qiskit/rustworkx) to enable scriptable, multi-language code manipulation at scale.
2626

27-
## Installation
27+
## Installation and Usage
2828
**This library requires Python 3.12 – 3.13.**
2929
```
30+
# Install inside existing project
3031
uv pip install codegen
32+
33+
# Install global CLI
34+
uv tool install codegen
35+
36+
# Create a codemod for a given repo
37+
cd path/to/repo
38+
codegen init
39+
codegen create test-function
40+
41+
# Run said codemod
42+
codegen run test-function
43+
44+
# Create an isolated venv with codegen => open jupyter
45+
codegen notebook
46+
```
47+
48+
## Usage
49+
50+
See [https://docs.codegen.com/introduction/getting-started] for a full tutorial.
51+
52+
```
53+
from codegen import Codebase
54+
3155
```
3256

3357
## Resources

docs/blog/act-via-code.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Provided a sufficiently comprehensive set of APIs, this paradigm has many clear
9292

9393
For software engineering, we believe the path forward is clear: agents need a framework that matches how developers think about and manipulate code. While decades of static analysis work gives us a strong foundation, traditional code modification frameworks weren't designed with AI-human collaboration in mind - they expose low-level APIs that don't match how developers (or AI systems) think about code changes.
9494

95-
We're building a framework with high-level APIs that correspond to how engineers actually think about code modifications. The APIs are clean and intuitive, following clear [principles](/docs/principles) that eliminate sharp edges and handle edge cases automatically. Most importantly, the framework encodes rich structural understanding of code. Consider this example:
95+
We're building a framework with high-level APIs that correspond to how engineers actually think about code modifications. The APIs are clean and intuitive, following clear [principles](/introduction/guiding-principles) that eliminate sharp edges and handle edge cases automatically. Most importantly, the framework encodes rich structural understanding of code. Consider this example:
9696

9797
```python
9898
# Access to high-level semantic operations
@@ -107,7 +107,7 @@ This isn't just string manipulation - the framework understands React component
107107

108108
The documentation for such a framework isn't just API reference - it's education for advanced intelligence about how to successfully manipulate code at scale. We're building for a future where AI systems are significant contributors to codebases, and they need to understand not just the "how" but the "why" behind code manipulation patterns.
109109

110-
Crucially, we believe these APIs will extend beyond the codebase itself into the broader software engineering ecosystem. When agents can seamlessly interact with tools like Datadog, AWS, and other development platforms through the same clean interfaces, we'll take a major step toward [autonomous software engineering](/about#our-mission). The highest leverage move isn't just giving agents the ability to modify code - it's giving them programmatic access to the entire software development lifecycle.
110+
Crucially, we believe these APIs will extend beyond the codebase itself into the broader software engineering ecosystem. When agents can seamlessly interact with tools like Datadog, AWS, and other development platforms through the same clean interfaces, we'll take a major step toward [autonomous software engineering](/introduction/about#our-mission). The highest leverage move isn't just giving agents the ability to modify code - it's giving them programmatic access to the entire software development lifecycle.
111111

112112
## Codegen is now OSS
113113

docs/building-with-codegen/symbol-api.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ icon: "shapes"
55
iconType: "solid"
66
---
77

8-
The [`Symbol`](/api-reference/core/Symbol) is the primary way developers interact with code in Codegen. It maps to how developers think about code - as functions, classes, variables, and other named entities.
8+
The [Symbol](/api-reference/core/Symbol) is the primary way developers interact with code in Codegen. It maps to how developers think about code - as functions, classes, variables, and other named entities.
99

10-
Both the [`Function`](/api-reference/core/Function) and [`Class`](/api-reference/core/Class) symbols are subclasses of the [`Symbol`](/api-reference/core/Symbol) class.
10+
Both the [Function](/api-reference/core/Function) and [Class](/api-reference/core/Class) symbols are subclasses of the [Symbol](/api-reference/core/Symbol) class.
1111

1212
## Accessing Symbols
1313

14-
The [`Codebase`](/api-reference/core/Codebase) class provides getters and iterators for functions, classes and symbols:
14+
The [Codebase](/api-reference/core/Codebase) class provides getters and iterators for functions, classes and symbols:
1515

1616
```python
1717
# Core symbol types
@@ -32,17 +32,17 @@ for symbol in codebase.functions + codebase.classes:
3232

3333
All symbols share common APIs for manipulation:
3434

35-
- The [`Editable`](/api-reference/core/Editable) API
35+
- The [Editable](/api-reference/core/Editable) API
3636
- Metadata
37-
- [`symbol.name`](/api-reference/core/Symbol#name)
38-
- [`symbol.source`](/api-reference/core/Symbol#source)
39-
- [`symbol.docstring`](/api-reference/core/Symbol#docstring)
37+
- [symbol.name](/api-reference/core/Symbol#name)
38+
- [symbol.source](/api-reference/core/Symbol#source)
39+
- [symbol.docstring](/api-reference/core/Symbol#docstring)
4040
- Edit operations
41-
- [`symbol.set_docstring`](/api-reference/core/Symbol#add_comment)
42-
- [`symbol.move_to_file`](/api-reference/core/Symbol#move-to-file) (see [Moving Symbols](/building-with-codegen/moving-symbols))
41+
- [symbol.set_docstring](/api-reference/core/Symbol#add_comment)
42+
- [symbol.move_to_file](/api-reference/core/Symbol#move-to-file) (see [Moving Symbols](/building-with-codegen/moving-symbols))
4343
- Graph relations (See [Usages and Dependencies](/building-with-codegen/dependencies-and-usages))
44-
- [`symbol.usages`](/api-reference/core/Symbol#usages)
45-
- [`symbol.dependencies`](/api-reference/core/Symbol#dependencies)
44+
- [symbol.usages](/api-reference/core/Symbol#usages)
45+
- [symbol.dependencies](/api-reference/core/Symbol#dependencies)
4646

4747
## Name operations
4848

docs/introduction/community.mdx

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,6 @@ Join the growing Codegen community! We're excited to have you be part of our jou
3636
Please help us improve this library and documentation by submitting a PR!
3737
</Tip>
3838

39-
## Community Channels
40-
41-
### Slack
42-
43-
Our [Slack community](https://community.codegen.com) is where you can:
44-
45-
- Get help and support
46-
- Share your Codegen projects
47-
- Connect with other developers
48-
- Stay updated on new features
49-
50-
### GitHub
51-
52-
Codegen is [open source](https://github.com/codegen-sh/codegen-sdk) and we welcome contributions! On GitHub you can:
53-
54-
- Report issues
55-
- Submit pull requests
56-
- Star the project
57-
- Browse the source code
58-
59-
### Twitter (X)
60-
61-
Follow us on [Twitter/X](https://x.com/codegen) to:
62-
63-
- Get the latest updates
64-
- See community highlights
65-
- Connect with the team
66-
- Share your Codegen wins
67-
6839
## Contributing
6940

7041
We welcome contributions of all kinds! Whether you're fixing a typo in documentation, reporting a bug, or implementing a new feature, we appreciate your help in making Codegen better.
@@ -75,5 +46,3 @@ Check out our [Contributing Guide](https://github.com/codegen-sh/codegen-sdk/blo
7546
- Submit pull requests
7647
- Report issues
7748
- Contribute to documentation
78-
79-
Together, we can build better tools for code transformation!

docs/introduction/faq.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ iconType: "solid"
4848
</Accordion>
4949
<Accordion title="Where can I get help if I'm stuck?" icon="life-ring">
5050
The best places to get help are:
51-
1. Our community Slack channel
52-
2. GitHub issues for bug reports
51+
1. Our community [Slack channel](https://community.codegen.com)
52+
2. [GitHub issues](https://github.com/codegen-sh/codegen-sdk) for bug reports
5353
3. Reach out to us on [Twitter](https://x.com/codegen)
5454
</Accordion>
5555
</AccordionGroup>

docs/introduction/how-it-works.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Codegen performs advanced static analysis to build a rich graph representation o
2121

2222
## The Codebase Graph
2323

24-
At the heart of Codegen is a comprehensive graph representation of your code. When you initialize a `[Codebase](/api-reference/core/Codebase)`, it performs static analysis to construct a rich graph structure connecting code elements:
24+
At the heart of Codegen is a comprehensive graph representation of your code. When you initialize a [Codebase](/api-reference/core/Codebase), it performs static analysis to construct a rich graph structure connecting code elements:
2525

2626
```python
2727
# Initialize and analyze the codebase

docs/introduction/overview.mdx

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,16 @@ iconType: "solid"
99

1010
It provides a scriptable interface to a powerful, multi-lingual language server built on top of [Tree-sitter](https://tree-sitter.github.io/tree-sitter/).
1111

12-
export const intoSnippet = `# grabs codebase content
13-
14-
file = codebase.files[0] # or .get_file("test.py")
15-
function = codebase.functions[0] # or .get_symbol("my_func")
16-
17-
# print logs
18-
19-
print(f'# of files: {len(codebase.files)}')
20-
print(f'# of functions: {len(codebase.functions)}')
21-
22-
# make edits
23-
24-
file.edit('🌈' + file.content) # edit contents
25-
function.rename('new_name') # rename
26-
function.set_docstring('new docstring') # set docstring
27-
28-
# ... etc.
29-
12+
export const intoSnippet = `# Codegen builds a complete graph connecting
13+
# functions, classes, imports and their relationships
14+
from codegen import Codebase
15+
16+
# Work with code without dealing with syntax trees or parsing
17+
for function in codebase.functions:
18+
# Comprehensive static analysis for references, dependencies, etc.
19+
if not function.usages:
20+
# Auto-handles references and imports to maintain correctness
21+
function.remove()
3022
`
3123

3224
<iframe
@@ -45,7 +37,11 @@ function.set_docstring('new docstring') # set docstring
4537
## Installation
4638

4739
```bash
40+
# Install CLI
4841
uv tool install codegen
42+
43+
# Install inside existing project
44+
pip install codegen
4945
```
5046

5147
## Get Started
@@ -86,7 +82,7 @@ Codegen was engineered backwards from real-world refactors we performed for ente
8682

8783
As AI becomes increasingly sophisticated, we're seeing a fascinating shift: AI agents aren't bottlenecked by their ability to understand code or generate solutions. Instead, they're limited by their ability to efficiently manipulate codebases. The challenge isn't the "brain" - it's the "hands."
8884

89-
We built Codegen with a key insight: future AI agents will need to ["act via code,"](https://voyager.minedojo.org/) building their own sophisticated tools for code manipulation. Rather than generating diffs or making direct text changes, these agents will:
85+
We built Codegen with a key insight: future AI agents will need to ["act via code,"](/blog/act-via-code) building their own sophisticated tools for code manipulation. Rather than generating diffs or making direct text changes, these agents will:
9086

9187
1. Express transformations as composable programs
9288
2. Build higher-level tools by combining primitive operations

docs/introduction/work-with-ai.mdx

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -96,39 +96,3 @@ This will ensure that the IDE's native chat model is aware of the APIs and commo
9696
## Devin, OpenHands and Semi-autonomous Code Agents
9797

9898
<Warning>Coming soon!</Warning>
99-
100-
## Coming Soon
101-
102-
<CardGroup cols={2}>
103-
<Card title="Default System Prompts" icon="download">
104-
Pre-built prompts for common transformation scenarios, ready to use with any
105-
AI.
106-
</Card>
107-
<Card title="Upgrade Paths" icon="arrow-up-right-dots">
108-
Specialized prompts for specific upgrade paths (React, TypeScript, etc.).
109-
</Card>
110-
</CardGroup>
111-
112-
## Best Practices
113-
114-
1. **Use Generated Prompts**: Let Codegen generate system prompts instead of writing them manually. They include important context about your codebase.
115-
116-
2. **Be Specific**: When creating a codemod, provide detailed descriptions to help the AI understand your goals:
117-
118-
```bash
119-
codegen create migrate-api --description "Update API calls to use the new v2 endpoints, handling pagination and error responses"
120-
```
121-
122-
3. **Leverage Context**: In Cursor, always @mention your codemod to give the AI full context about your transformation.
123-
124-
4. **Iterative Refinement**: Use AI suggestions as a starting point, then refine based on your specific needs.
125-
126-
<Note>
127-
The system prompts are designed to be human-readable. Review them to
128-
understand what context is being provided to the AI.
129-
</Note>
130-
131-
<Tip>
132-
You can also use the generated system prompts with other AI tools - just copy
133-
the prompt content and paste it into your preferred AI interface.
134-
</Tip>

0 commit comments

Comments
 (0)