โ๏ธ Configuration โ early generate-for-project
The early generate-for-project CLI command lets you boost coverage across a selected folder or file.
It accepts configuration via CLI flags or environment variables.
For memory, tokens, formatting, or concurrency guidance, refer to:
๐ Required Inputsโ
These flags are required for both JavaScript/TypeScript and Python projects:
| Variable | CLI Flag | Description | Required | Default |
|---|---|---|---|---|
| API_KEY | -k, --api-key | Early API key | โ Yes | โ |
| TOKEN | -t, --token | SCM token with repo access | โ Yes | โ |
| TARGET_DIRECTORY | --target-directory | File or directory to scan for untested code | โ Yes | โ |
| REF_NAME | --ref-name | Git branch name | โ Yes | โ |
โ๏ธ Optional Inputsโ
- JavaScript / TypeScript
- Python
| Variable | CLI Flag | Description | Default |
|---|---|---|---|
| TEST_STRUCTURE | -s, --test-structure | Folder structure: siblingFolder or rootFolder. | siblingFolder |
| TEST_FRAMEWORK | -f, --test-framework | Test framework: jest, mocha, etc. | jest |
| TEST_FILE_SUFFIX | --test-suffix | Test file suffix (e.g. test, spec). | test |
| TEST_FILE_NAMING | --test-file-naming | Naming style: camelCase, snake_case, kebab-case. | camelCase |
| MAX_TESTABLES | --max-testables | Max number of methods to generate tests for. See MAX testables | 30 |
| SKIP_COVERAGE_AFTER | --skip-coverage-after | Skip calculating coverage after test generation. See Skip coverage after | false |
| MAX_CONCURRENCY | -c, --max-concurrency | Parallel workers (1โ4). See Concurrency Guide | 1 |
| AUTO_COMMIT | --auto-commit | Commit generated files: true or false. | true |
| TEST_COMMAND | --test-command | Validate tests via custom command | See Agent Jest Commands โ |
| COVERAGE_COMMAND | --coverage-command | Custom command to collect coverage | See Agent Jest Commands โ |
| CONTINUE-ON_TEST_ERRORS | --continue-on-test-errors | Continue the operation if current tests fail. | See Agent Jest Commands - tests fail โ |
| LINT_COMMAND | --lint-command | Linting command. See Lint & Format | npx --no eslint $early_filename --fix |
| PRETTIER_COMMAND | --prettier-command | Prettier formatting command. See Lint & Format | npx --no prettier $early_filename --write |
| GIT_USER_EMAIL | --git-user-email | Commit author email | 217573370+Early-Agent[bot]@users.noreply.github.com |
| GIT_USER_NAME | --git-user-name | Commit author name | โ |
| SCM_PROVIDER | --scm-provider | github, bitbucket, etc. See SCM Support |
โ ๏ธ If using MAX_CONCURRENCY>1, set NODE_OPTIONS for memory:
export NODE_OPTIONS="--max-old-space-size=5120"
| Variable | CLI Flag | Description | Default |
|---|---|---|---|
| TEST_STRUCTURE | -s, --test-structure | Folder structure: siblingFolder or rootFolder. | siblingFolder |
| TEST_FILE_NAMING | --test-file-naming | Naming style: camelCase or kebabCase. | camelCase |
| MAX_CONCURRENCY | -c, --max-concurrency | Parallel workers (1โ3). | 3 |
| AUTO_COMMIT | --auto-commit | Commit and push generated test files: true or false. | true |
| AUTO_COMMIT_SKIP_CI | --auto-commit-skip-ci | Append [skip ci] to the auto-commit message. | true |
| GIT_USER_EMAIL | --git-user-email | Commit author email. | Early-Agent[bot] noreply address |
| GIT_USER_NAME | --git-user-name | Commit author name. | early-agent[bot] |
| SCM_PROVIDER | --scm-provider | github or bitbucket. See SCM Support | github |
Note: The test framework is automatically set to pytest for Python projects. Options like
--test-command,--coverage-command,--lint-command, and--prettier-commandare not yet supported for Python.
Auto-commit and required inputsโ
When AUTO_COMMIT is enabled (the default), the CLI checks out the branch specified by REF_NAME, commits any generated .early. test files, and pushes to the remote. This requires:
TOKENโ used to authenticate thegit push. The token must have write access to the repository.REF_NAMEโ the branch to check out and push to. Must exist on the remote.
Set AUTO_COMMIT=false if you want to inspect generated tests before committing, or if your CI pipeline handles commits separately.
๐งน Recommended Formattingโ
- JavaScript / TypeScript
- Python
If your repository enforces linting or formatting rules, you should define custom commands to align with them.
See this guide to see the defaults and how to change them if needed Lint & Format โ
Lint and formatting hooks are not yet supported for Python projects. Generated test files follow standard pytest conventions.
๐ก Example: CLI Invocationโ
- JavaScript / TypeScript
- Python
early generate-for-project \
--api-key <your_api_key> \
--token <your_github_token> \
--target-directory <path_to_file_or_directory> \
--ref-name <branch_name>
early generate-for-project \
--api-key <your_api_key> \
--token <your_github_token> \
--target-directory <path_to_file_or_directory> \
--ref-name <branch_name>
--target-directorycan be a single.pyfile (e.g.,src/utils/helpers.py) or a folder (e.g.,src/). When given a folder, all.pyfiles are scanned recursively.
โ Best Practiceโ
Prefer environment variables in CI for simplicity and safety. Avoid logging secrets in plaintext.