| name | implement-command |
| description | Use when adding or updating Redis command support in ioredis, including command metadata checks, generator inputs under bin/, generated RedisCommander typings, return and argument overrides, functional command tests, optional tsd coverage, and validation. |
Implement Command
Use this skill when adding a missing Redis command, correcting an existing command signature, changing command return types, or adding coverage for command-specific Buffer, callback, pipeline, or transformer behavior.
Command Support Map
@ioredis/commands: upstream command metadata consumed by the generator.
bin/index.js: generator entry point for lib/utils/RedisCommander.ts.
bin/returnTypes.js: command return type map. Most new commands need an entry here.
bin/argumentTypes.js: command-specific argument shape overrides when metadata or global mapping is insufficient.
bin/typeMaps.js: global Redis argument category to TypeScript type mapping.
bin/overrides.js: manual overloads for signatures the generator cannot express cleanly.
bin/sortArguments.js: argument reordering for commands whose generated order is wrong.
lib/utils/RedisCommander.ts: generated declarations. Regenerate it; do not hand-edit it.
lib/Command.ts: command argument and reply transformer registry. Touch only when transformer behavior is needed.
test/functional/commands/<command>.ts: runtime command coverage.
test/functional/transformer.ts: transformer runtime coverage.
test/typing/commands.test-d.ts: public command typing coverage.
test/typing/transformers.test-d.ts: transformer typing coverage.
Workflow
-
Establish command scope.
- Normalize command keys to lowercase, matching
bin/returnTypes.js.
- Resolve command aliases or subcommands before editing.
- Confirm the command exists in
@ioredis/commands. If it is missing there, stop and report that the metadata package must be updated before ioredis can generate typed command support.
- Identify the minimum Redis server version needed and whether functional tests must be version-gated.
-
Inspect current support.
- Search
lib/utils/RedisCommander.ts, bin/, test/functional/commands/, and test/typing/ for the command and related aliases.
- Inspect nearby command families before choosing types, for example hash expiration commands, sorted-set commands, stream commands, or pub/sub commands.
- Check existing argument and reply transformers before adding new ones.
-
Update generator inputs.
- Prefer
bin/returnTypes.js for return type corrections.
- Use a string return type for simple fixed replies.
- Use a function return type when replies depend on subcommands, options, or tokens.
- Reuse
hasToken and matchSubcommand in bin/returnTypes.js when they fit.
- Use
bin/argumentTypes.js only for command-specific argument overrides.
- Use
bin/typeMaps.js only for broad metadata category fixes that should affect multiple commands.
- Use
bin/overrides.js only when generated overloads cannot express the supported API cleanly.
- Keep command names lowercase in generator maps unless the surrounding file uses another established convention.
-
Regenerate declarations.
- In this repo, use
node bin/index.js unless package.json later adds an explicit generation script.
- Review the generated diff in
lib/utils/RedisCommander.ts.
- Check the normal method, callback overload, pipeline/transaction shape, and Buffer variant when the command returns strings, arrays, nullable bulk replies, or transformed objects.
- If generation changes unrelated commands, inspect the generator input and do not accept surprising churn without an explanation.
-
Add focused runtime coverage.
Completion Report
Report:
- Commands added or updated.
- Metadata/generator inputs changed.
- Generated files changed.
- Functional tests added or updated.
- Typing tests added or updated.
- Documentation decision.
- Validation commands run and results.
- Skipped validation with the concrete reason, including Redis version or local environment limits.