> ## Documentation Index
> Fetch the complete documentation index at: https://docs.patched.codes/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating Steps

> Creating custom steps for unique tasks

The core set of Steps provided by Patched are designed to cover a wide range of common tasks in software development. However, there are always unique tasks that require custom steps. Patched allows you to create custom steps to automate these tasks.

## <Icon icon="window" />  Dashboard

<Info> Only available to Pro and Enterprise users </Info>

<Steps>
  <Step title="Navigate">In the patchflow builder's Steps sidebar, click the `Add Step` icon next to the search box.</Step>

  <Step title="Describe">Describe the Step you wish to create in plain text, and provide the input and output schema.</Step>

  <Step title="Review">Review the generated code for the step and modify it as needed.</Step>

  <Step title="Validate">Validate the step by providing a sample input and clicking the `Validate` button.</Step>

  <Step title="Save">Once the step is validated, click the `Save` button. The step will now be available in the Steps sidebar for use in patchflows.</Step>
</Steps>

## <Icon icon="rectangle-terminal" />  CLI

<Steps>
  <Step title="Fork">Fork the patchwork template repository to your machine.</Step>
  <Step title="Directory">Create a new folder for the step in the `patchwork/steps` directory with `StepName`.</Step>
  <Step title="Step File">Create a file named `StepName.py` in the newly created directory. Any additional files required for the step should be placed in the same folder.</Step>

  <Step title="Code">
    Implement the step logic in the `StepName.py` file. The step should inherit from the `Step` class provided by Patched. The `StepName` class is expected to have two methods:

    * **init**: The constructor of the class. It should accept an inputs dictionary as an argument. This dictionary contains the input data for the step. Checking of the presence and validity of the input data should be done here.
    * **run**: The main method of the class. This method should contain the logic of the step and return a dictionary with the results.
  </Step>

  <Step title="Initialize">
    Update patchwork/steps/**init**.py to include the new step in the list of available steps.
  </Step>
</Steps>

Below is an example of a custom step that takes two inputs and returns an output. For more details, view the Patchwork CLI documentation.

```python theme={null}
Example
Path: patchwork/steps/RunExample/RunExample.py
from patchwork.step import Step


class RunExample(Step):
    required_keys = ['input1', 'input2']

    def __init__(self, inputs):
        super().__init__(inputs)
        for key in self.required_keys:
            if key not in inputs:
                raise ValueError(f"Missing required input: {key}")

        self.input1 = inputs['input1']
        self.input2 = inputs['input2']

    def run(self) -> dict:
        return {
            'output1': "example output",
        }
Path: patchwork/steps/__init__.py
from .RunExample.RunExample import RunExample

__all__ = [
    ...
    'RunExample',
]
```
