| name | scaffold-algorithm |
| description | Scaffold a new sorting algorithm: generates the generator file, pure sort function, and Vitest test file from templates, then registers it in the index and constants. Use when adding any new sorting algorithm to the project. |
| argument-hint | <kebab-case-algorithm-name> e.g. shell-sort |
Scaffold Algorithm
Creates a complete, test-covered sorting algorithm from templates.
When to Use
- Adding any new sorting algorithm to the project
- Ensures consistent file structure, export names, and test coverage
Procedure
-
Determine the algorithm name in three forms:
- kebab-case: the argument provided (e.g.
shell-sort)
- camelCase: for function names (e.g.
shellSort)
- Display name: for the UI registry (e.g.
Shell Sort)
-
Copy and fill algorithm template → src/algorithms/<kebab-name>.ts
- Replace all
__NAME__ placeholders with the camelCase name
- Implement the actual algorithm logic
-
Copy and fill test template → src/algorithms/<kebab-name>.test.ts
- Replace all
__NAME__ and __DISPLAY_NAME__ placeholders
-
Add to src/algorithms/index.ts:
export { __NAME__Steps, __NAME__Sort } from './<kebab-name>'
-
Add an AlgorithmMeta entry to src/constants/algorithms.ts
-
Run tests: npm run test:run -- <kebab-name>