> ## Documentation Index
> Fetch the complete documentation index at: https://codegeninc-fix-system-prompt-typo.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Command

The `create` command generates a new codemod function with the necessary boilerplate.

```bash theme={null}
codegen create rename-function .
```

## Usage

```bash theme={null}
codegen create NAME PATH [OPTIONS]
```

## Arguments

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

## Options

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

## Generated Files

When you run `codegen create rename-function .`, it creates:

```
.codegen/
└── codemods/
    └── rename_function/
        ├── rename_function.py              # The codemod implementation
        └── rename_function-system-prompt.txt  # System prompt (if --description used)
```

The generated codemod will have this structure:

```python theme={null}
import codegen
from codegen import Codebase

@codegen.function("rename-function")
def run(codebase: Codebase):
    """Add a description of what this codemod does."""
    # Add your code here
    print('Total files: ', len(codebase.files))
    print('Total functions: ', len(codebase.functions))
    print('Total imports: ', len(codebase.imports))

if __name__ == "__main__":
    print('Parsing codebase...')
    codebase = Codebase("./")

    print('Running...')
    run(codebase)
```

## Examples

Create a basic codemod:

```bash theme={null}
codegen create rename-function .
```

Create with an AI-powered implementation:

```bash theme={null}
codegen create rename-function . -d "Rename the getUserData function to fetchUserProfile"
```

## Next Steps

After creating a codemod:

1. Edit the implementation in the generated .py file
2. Test it with `codegen run rename-function`
3. Deploy it for team use with `codegen deploy rename-function`

## Common Issues

If you see "File already exists":

1. Choose a different name for your codemod, or
2. Use the `--overwrite` flag to replace the existing file

<Note>
  The codemod name will be converted to snake\_case for the Python file (e.g., `update-imports` becomes `update_imports.py`).
</Note>
