Spec Version:
End-to-End Walkthrough: Transformations Management with Rudder CLI Beta
- free
- growth
- enterprise
5 minute read
In this tutorial, you will use the Rudder CLI tool to define, validate, test, and apply transformations from your local project.
Prerequisites
- Rudder CLI tool (
rudder-cli) installed locally - A project directory with your transformation YAML files
- In your RudderStack workspace, create a workspace-level Service Access Token with the following permissions:
- If you’re on Free or self-hosted plan, or for testing and development only: Generate a Personal Access Token with Read-Write role
Any action authenticated by a Personal Access Token will break if the user generating the token is removed from the organization or there is a breaking change to their permissions.
Token permissions for legacy RBAC system
If you are on the legacy Permissions Management (RBAC) system, your workspace-level Service Access Token should have the Admin role and Grant edit access toggled on under Transformations.
See Generate a workspace-level Service Access Token for steps to create the token.

1. Authenticate the CLI tool
Run the following command and enter your access token when prompted:
rudder-cli auth login
2. Create a project directory
Create a project directory to store your transformation specs, code, and tests:
mkdir -p ~/tutorial-transformations/transformations
Example structure:
tutorial-transformations/
└── transformations/
├── my-transformation.yaml
├── my-library.yaml
├── my-python-transformation.yaml
├── my-python-library.yaml
├── javascript/
│ ├── my-transformation.js
│ └── my-library.js
├── python/
│ ├── my-python-transformation.py
│ └── my-python-library.py
└── tests/
├── input/
│ └── product_clicked.json
└── output/
└── product_clicked.json
RudderStack supports Python transformation libraries only in the Growth and Enterprise plans.
3. Add a transformation spec
This section lists the steps to create a transformation YAML spec via the following methods:
Referencing an external file
- Create the YAML spec for your transformation:
- Create the transformation code file:
Using inline code
You can also write transformation code directly in the YAML spec using code instead of referencing an external file with file:
codeandfileare mutually exclusive — use one or the other in a given spec. See the Transformation YAML Reference for the complete schema.
4. Add a transformation library spec
Create the YAML spec for your transformation library:
Then, create the library code file:
For library resources,import_namemust be the camelCase form ofname. For example,name: my librarymaps toimport_name: myLibraryandname: my python librarymaps toimport_name: myPythonLibrary.
5. Validate YAML and code references
Run validation from the project root:
rudder-cli validate -l ~/tutorial-transformations
This command validates required fields, code/file rules, supported languages, code syntax, and test definitions.
6. Test transformations locally
Rudder CLI supports 3 test modes:
You cannot include multiple test modes in a single command.
- Test a specific transformation by ID:
rudder-cli transformations test my-transformation -l ~/tutorial-transformations
- Test all transformations:
rudder-cli transformations test --all -l ~/tutorial-transformations
- Test only new or modified transformations:
rudder-cli transformations test --modified -l ~/tutorial-transformations
Optional
- Show detailed failures and diffs:
rudder-cli transformations test --all --verbose -l ~/tutorial-transformations
- Show the built-in default events:
rudder-cli transformations show-default-events
How it works
When running tests, Rudder CLI loads input files from each test suite’s input path. If a matching output file (same filename) exists in the output path, it compares the actual output against the expected output. If no matching output file exists, the test still runs but skips the output comparison.
Rudder CLI tests the transformation using default RudderStack events if:
spec.testsisn’t configured, or- No input JSON files are found in the configured input paths
See the Rudder CLI transformations testing framework section for more details.
7. Apply changes
- Optional dry-run:
rudder-cli apply -l ~/tutorial-transformations --dry-run
- Apply to workspace:
rudder-cli apply -l ~/tutorial-transformations
Next steps
- See the Transformation YAML Reference for detailed resource schemas and constraints
- See Manage Transformations Using Rudder CLI for the overall CLI workflow
- Automate with GitHub Actions
