Skip to content

Commit b4e906c

Browse files
fix: Update docs for codegen create command to include required PATH parameter (#963)
Recommended by @enismaxim1 This PR updates the documentation for the `codegen create` command to correctly include the required PATH parameter. ## Changes - Updated examples in various documentation files to show the correct usage: `codegen create my-function . -d "describe what you want to do"` - Added explanations about the PATH parameter being required - Updated command usage syntax in the create.mdx file - Fixed examples in init.mdx, dot-codegen.mdx, reusable-codemods.mdx, and work-with-ai.mdx This addresses the issue reported in Slack where the instructions after running `codegen init` were incorrect, as they didn't include the required PATH parameter. Fixes the issue where users were seeing errors when following the documentation without specifying a path. Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
1 parent d981477 commit b4e906c

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

docs/building-with-codegen/dot-codegen.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Codegen automatically adds appropriate entries to your `.gitignore`:
7878
The `codemods/` directory is where your transformation functions live. You can create new codemods using:
7979

8080
```bash
81-
codegen create my-codemod [--description "what it does"]
81+
codegen create my-codemod PATH [--description "what it does"]
8282
```
8383

8484
This will:
@@ -115,7 +115,7 @@ After initializing your `.codegen` directory:
115115

116116
1. Create your first codemod:
117117
```bash
118-
codegen create my-codemod -d "describe what you want to do"
118+
codegen create my-codemod . -d "describe what you want to do"
119119
```
120120

121121
2. Run it:

docs/building-with-codegen/reusable-codemods.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Codegen enables you to create reusable code transformations using Python functio
1212
The easiest way to create a new codemod is using the CLI [create](/cli/create) command:
1313

1414
```bash
15-
codegen create rename-function
15+
codegen create rename-function .
1616
```
1717

1818
This creates a new codemod in your `.codegen/codemods` directory:
@@ -37,7 +37,7 @@ def run(codebase: Codebase):
3737
You can use AI to generate an initial implementation by providing a description:
3838

3939
```bash
40-
codegen create rename-function -d "Rename the getUserData function to fetchUserProfile"
40+
codegen create rename-function . -d "Rename the getUserData function to fetchUserProfile"
4141
```
4242

4343
This will:

docs/cli/create.mdx

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,27 @@ iconType: "solid"
88
The `create` command generates a new codemod function with the necessary boilerplate.
99

1010
```bash
11-
codegen create rename-function
11+
codegen create rename-function .
1212
```
1313

1414
## Usage
1515

1616
```bash
17-
codegen create NAME [OPTIONS]
17+
codegen create NAME PATH [OPTIONS]
1818
```
1919

2020
## Arguments
2121

2222
- `NAME`: The name of the codemod to create (e.g., "rename-function")
23+
- `PATH`: The path where the codemod should be created (e.g., "." for current directory)
2324

2425
## Options
2526

2627
- `--description`, `-d`: A description of what the codemod should do. This will be used to generate an AI-powered implementation.
2728

2829
## Generated Files
2930

30-
When you run `codegen create rename-function`, it creates:
31+
When you run `codegen create rename-function .`, it creates:
3132

3233
```
3334
.codegen/
@@ -63,12 +64,12 @@ if __name__ == "__main__":
6364

6465
Create a basic codemod:
6566
```bash
66-
codegen create rename-function
67+
codegen create rename-function .
6768
```
6869

6970
Create with an AI-powered implementation:
7071
```bash
71-
codegen create rename-function -d "Rename the getUserData function to fetchUserProfile"
72+
codegen create rename-function . -d "Rename the getUserData function to fetchUserProfile"
7273
```
7374

7475
## Next Steps

docs/cli/init.mdx

+3-1
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ After initializing:
9292
1. Create your first codemod:
9393

9494
```bash
95-
codegen create my-function -d "describe what you want to do"
95+
codegen create my-function . -d "describe what you want to do"
9696
```
9797

98+
Note: The second parameter (`.`) specifies the path where the codemod should be created. This is required.
99+
98100
2. Run it:
99101

100102
```bash

docs/introduction/work-with-ai.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The [Codegen CLI](/cli/about) provides commands to generate `.md` files that can
2828
When you create a new codemod via [codegen create](/cli/create):
2929

3030
```bash
31-
codegen create delete-dead-imports --description "Delete unused imports"
31+
codegen create delete-dead-imports . --description "Delete unused imports"
3232
```
3333

3434
Codegen automatically generates an optimized ["system prompt"](https://news.ycombinator.com/item?id=37880023) that includes:
@@ -52,7 +52,7 @@ This `.md` file can be used with any AI assistant (Claude, GPT-4, etc.) to get m
5252
<Step title="Create a codemod with description">
5353
Use the [create command](/cli/create) with a detailed description of what you want to accomplish:
5454
```bash
55-
codegen create modernize-components --description "Convert class components to functional components with hooks"
55+
codegen create modernize-components . --description "Convert class components to functional components with hooks"
5656
```
5757
</Step>
5858
<Step title="Review the generated system prompt">

src/codegen/cli/commands/init/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ def init_command(path: str | None = None, token: str | None = None, language: st
4646
# Print next steps
4747
rich.print("\n[bold]What's next?[/bold]\n")
4848
rich.print("1. Create a function:")
49-
rich.print(format_command('codegen create my-function -d "describe what you want to do"'))
49+
rich.print(format_command('codegen create my-function . -d "describe what you want to do"'))
5050
rich.print("2. Run it:")
5151
rich.print(format_command("codegen run my-function --apply-local"))

0 commit comments

Comments
 (0)