{"owner":"redis","repo":"ioredis","hasSkills":true,"hasMcp":false,"mcpConfig":null,"found":["AGENTS.md"],"skills":{"AGENTS.md":"# AGENTS.md\n\nThis file provides guidance to AI coding agents (Claude Code, Codex, Copilot, Cursor, Aider, etc.) when working with code in this repository.\n\n## Project Overview\n\nioredis is a full-featured Redis client for Node.js, written 100% in TypeScript. Source lives in `lib/`, compiles to CommonJS in `built/` (the published artifact), and supports standalone, Sentinel, and Cluster topologies.\n\n## Common Commands\n\n### Building\n\n```bash\nnpm run build          # Wipe built/ and compile TypeScript\nnode bin/index.js      # Regenerate lib/utils/RedisCommander.ts\n```\n\n### Linting and Formatting\n\n```bash\nnpm run lint           # Run ESLint over lib/\nnpm run format         # Format files with Prettier\nnpm run format-check   # Check formatting\n```\n\n### Testing\n\nFunctional and cluster tests require running Redis servers. Unit tests under `test/unit/` mock the network and do not need a server.\n\nTo start and stop local Redis test infrastructure:\n\n```bash\nnpm run docker:setup      # Start standalone Redis on 6379 and cluster nodes on 3000-3005\nnpm run docker:teardown   # Stop test Redis servers\n```\n\n```bash\nnpm test                  # Default non-cluster test: test:js then test:tsd\nnpm run test:js           # Mocha over test/helpers, test/unit, test/functional\nnpm run test:cluster      # Mocha over test/cluster\nnpm run test:tsd          # Build then run tsd against test/typing\nnpm run test:cov          # Test coverage\n\n# Run a single test file\nTS_NODE_TRANSPILE_ONLY=true NODE_ENV=test npx mocha --no-experimental-strip-types \"test/unit/foo.ts\"\n\n# Run a single test by name\nTS_NODE_TRANSPILE_ONLY=true NODE_ENV=test npx mocha --no-experimental-strip-types \"test/unit/foo.ts\" --grep \"partial test title\"\n```\n\n## Generated Code\n\n**Do not hand-edit**: `lib/utils/RedisCommander.ts` (generated), `built/` (build output), and `node_modules/`.\n\n`lib/utils/RedisCommander.ts` holds the typed signatures for every Redis command. This is what gives calls like `redis.set(...)` their types.\n\nRegenerate it with:\n\n```bash\nnode bin/index.js\n```\n\nGeneration uses `@ioredis/interface-generator` plus per-command config in `bin/`:\n\n- **`bin/template.ts`** — File skeleton; generated interface is spliced into the `////` marker.\n- **`bin/overrides.js`** — Hand-written signatures for commands the generator gets wrong, such as `hgetall` and `mset`.\n- **`bin/argumentTypes.js`**, **`bin/returnTypes.js`**, **`bin/sortArguments.js`**, **`bin/typeMaps.js`** — Argument and return type mapping and ordering.\n\nWhen adding command typing support, edit the `bin/` config and regenerate. Never patch `RedisCommander.ts` directly.\n\n## Architecture\n\n### Layered Design\n\n```text\nPublic API (`Redis`, `Cluster`, `Pipeline`, `Command`, options)\n  → Command facade (`Commander`, generated `RedisCommander` typings, Lua scripts)\n    → Command objects and queues (`Command`, offline queue, command queue, pipeline queue)\n      → Topology routing (standalone, Sentinel, Cluster slots, subscriber groups)\n        → Connection layer (`connectors/`, `redis/event_handler.ts`, retry and ready checks)\n          → RESP parsing and reply handling (`DataHandler`, `redis-parser`)\n```\n\n### Key Source Areas\n\n- **`lib/index.ts`** — Public export surface for the package. Changes here affect the published TypeScript declarations and user-facing API.\n- **`lib/Redis.ts`** — Main standalone and Sentinel client. Manages connection lifecycle (`wait → connecting → connect → ready → close → reconnecting → end`), offline queue behavior, reconnection strategy, and connector selection.\n- **`lib/utils/Commander.ts`** — Shared command facade for `Redis` and `Cluster`. Dynamically attaches builtin Redis commands, string and `Buffer` variants, autopipelining dispatch, direct `sendCommand`, and `defineCommand` Lua registration.\n- **`lib/Command.ts`** — Single Redis command representation. Handles argument transformation, reply transformation, promise/callback resolution, key-slot calculation, and subscriber/monitor-mode command flags.\n- **`lib/DataHandler.ts`** — Parser and reply dispatcher. Wraps `redis-parser`, consumes socket data, resolves queued commands, and routes Pub/Sub replies and monitor messages.\n- **`lib/connectors/`** — Network connector implementations. `StandaloneConnector` handles TCP/TLS sockets; `SentinelConnector/` resolves masters through Sentinel using `FailoverDetector` and `SentinelIterator`.\n- **`lib/cluster/`** — Cluster client, per-node connection pool, slot cache refresh, redirection handling for `MOVED` and `ASK`, retry scheduling, and cluster Pub/Sub through `ClusterSubscriber`, `ShardedSubscriber`, and `ClusterSubscriberGroup`.\n- **`lib/Pipeline.ts`** and **`lib/transaction.ts`** — Batched command execution. `pipeline()` is non-atomic batching; `multi()` adds MULTI/EXEC transaction behavior.\n- **`lib/autoPipelining.ts`** — Same-tick command batching. `notAllowedAutoPipelineCommands` lists commands that must bypass autopipelining, such as auth, subscribe, and multi.\n- **`lib/Script.ts`** — Lua script abstraction used by `defineCommand`, with `EVALSHA` execution and `EVAL` fallback.\n- **`lib/ScanStream.ts`** — Readable stream wrapper for `SCAN`, `HSCAN`, `SSCAN`, and `ZSCAN`.\n- **`lib/tracing.ts`** — Command and connection tracing hooks with argument sanitization.\n\n### How Commands Execute\n\n1. User calls a method such as `redis.get()` or `cluster.set()`.\n2. `Commander` routes the call through autopipelining, pipeline/transaction handling, or direct `sendCommand`.\n3. A `Command` object is created with transformed arguments and callback/promise state.\n4. Standalone clients enqueue the command on one connection; Cluster clients choose a node by key slot and may retry on redirects.\n5. The command is written to the socket after connection readiness checks and offline queue handling.\n6. `redis-parser` parses the RESP reply from the socket.\n7. `DataHandler` resolves the matching queued command, applies reply transformers, and emits Pub/Sub or monitor events when relevant.\n\n## Commit Messages\n\nFollow [Conventional Commits](https://www.conventionalcommits.org/): `<type>: <subject>`.\n\nCommon types include `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, and `chore`.\n\nReleases are automated via semantic-release (`.releaserc.json`), so commit messages drive the changelog and version bump.\n"},"files":{"AGENTS.md":"# AGENTS.md\n\nThis file provides guidance to AI coding agents (Claude Code, Codex, Copilot, Cursor, Aider, etc.) when working with code in this repository.\n\n## Project Overview\n\nioredis is a full-featured Redis client for Node.js, written 100% in TypeScript. Source lives in `lib/`, compiles to CommonJS in `built/` (the published artifact), and supports standalone, Sentinel, and Cluster topologies.\n\n## Common Commands\n\n### Building\n\n```bash\nnpm run build          # Wipe built/ and compile TypeScript\nnode bin/index.js      # Regenerate lib/utils/RedisCommander.ts\n```\n\n### Linting and Formatting\n\n```bash\nnpm run lint           # Run ESLint over lib/\nnpm run format         # Format files with Prettier\nnpm run format-check   # Check formatting\n```\n\n### Testing\n\nFunctional and cluster tests require running Redis servers. Unit tests under `test/unit/` mock the network and do not need a server.\n\nTo start and stop local Redis test infrastructure:\n\n```bash\nnpm run docker:setup      # Start standalone Redis on 6379 and cluster nodes on 3000-3005\nnpm run docker:teardown   # Stop test Redis servers\n```\n\n```bash\nnpm test                  # Default non-cluster test: test:js then test:tsd\nnpm run test:js           # Mocha over test/helpers, test/unit, test/functional\nnpm run test:cluster      # Mocha over test/cluster\nnpm run test:tsd          # Build then run tsd against test/typing\nnpm run test:cov          # Test coverage\n\n# Run a single test file\nTS_NODE_TRANSPILE_ONLY=true NODE_ENV=test npx mocha --no-experimental-strip-types \"test/unit/foo.ts\"\n\n# Run a single test by name\nTS_NODE_TRANSPILE_ONLY=true NODE_ENV=test npx mocha --no-experimental-strip-types \"test/unit/foo.ts\" --grep \"partial test title\"\n```\n\n## Generated Code\n\n**Do not hand-edit**: `lib/utils/RedisCommander.ts` (generated), `built/` (build output), and `node_modules/`.\n\n`lib/utils/RedisCommander.ts` holds the typed signatures for every Redis command. This is what gives calls like `redis.set(...)` their types.\n\nRegenerate it with:\n\n```bash\nnode bin/index.js\n```\n\nGeneration uses `@ioredis/interface-generator` plus per-command config in `bin/`:\n\n- **`bin/template.ts`** — File skeleton; generated interface is spliced into the `////` marker.\n- **`bin/overrides.js`** — Hand-written signatures for commands the generator gets wrong, such as `hgetall` and `mset`.\n- **`bin/argumentTypes.js`**, **`bin/returnTypes.js`**, **`bin/sortArguments.js`**, **`bin/typeMaps.js`** — Argument and return type mapping and ordering.\n\nWhen adding command typing support, edit the `bin/` config and regenerate. Never patch `RedisCommander.ts` directly.\n\n## Architecture\n\n### Layered Design\n\n```text\nPublic API (`Redis`, `Cluster`, `Pipeline`, `Command`, options)\n  → Command facade (`Commander`, generated `RedisCommander` typings, Lua scripts)\n    → Command objects and queues (`Command`, offline queue, command queue, pipeline queue)\n      → Topology routing (standalone, Sentinel, Cluster slots, subscriber groups)\n        → Connection layer (`connectors/`, `redis/event_handler.ts`, retry and ready checks)\n          → RESP parsing and reply handling (`DataHandler`, `redis-parser`)\n```\n\n### Key Source Areas\n\n- **`lib/index.ts`** — Public export surface for the package. Changes here affect the published TypeScript declarations and user-facing API.\n- **`lib/Redis.ts`** — Main standalone and Sentinel client. Manages connection lifecycle (`wait → connecting → connect → ready → close → reconnecting → end`), offline queue behavior, reconnection strategy, and connector selection.\n- **`lib/utils/Commander.ts`** — Shared command facade for `Redis` and `Cluster`. Dynamically attaches builtin Redis commands, string and `Buffer` variants, autopipelining dispatch, direct `sendCommand`, and `defineCommand` Lua registration.\n- **`lib/Command.ts`** — Single Redis command representation. Handles argument transformation, reply transformation, promise/callback resolution, key-slot calculation, and subscriber/monitor-mode command flags.\n- **`lib/DataHandler.ts`** — Parser and reply dispatcher. Wraps `redis-parser`, consumes socket data, resolves queued commands, and routes Pub/Sub replies and monitor messages.\n- **`lib/connectors/`** — Network connector implementations. `StandaloneConnector` handles TCP/TLS sockets; `SentinelConnector/` resolves masters through Sentinel using `FailoverDetector` and `SentinelIterator`.\n- **`lib/cluster/`** — Cluster client, per-node connection pool, slot cache refresh, redirection handling for `MOVED` and `ASK`, retry scheduling, and cluster Pub/Sub through `ClusterSubscriber`, `ShardedSubscriber`, and `ClusterSubscriberGroup`.\n- **`lib/Pipeline.ts`** and **`lib/transaction.ts`** — Batched command execution. `pipeline()` is non-atomic batching; `multi()` adds MULTI/EXEC transaction behavior.\n- **`lib/autoPipelining.ts`** — Same-tick command batching. `notAllowedAutoPipelineCommands` lists commands that must bypass autopipelining, such as auth, subscribe, and multi.\n- **`lib/Script.ts`** — Lua script abstraction used by `defineCommand`, with `EVALSHA` execution and `EVAL` fallback.\n- **`lib/ScanStream.ts`** — Readable stream wrapper for `SCAN`, `HSCAN`, `SSCAN`, and `ZSCAN`.\n- **`lib/tracing.ts`** — Command and connection tracing hooks with argument sanitization.\n\n### How Commands Execute\n\n1. User calls a method such as `redis.get()` or `cluster.set()`.\n2. `Commander` routes the call through autopipelining, pipeline/transaction handling, or direct `sendCommand`.\n3. A `Command` object is created with transformed arguments and callback/promise state.\n4. Standalone clients enqueue the command on one connection; Cluster clients choose a node by key slot and may retry on redirects.\n5. The command is written to the socket after connection readiness checks and offline queue handling.\n6. `redis-parser` parses the RESP reply from the socket.\n7. `DataHandler` resolves the matching queued command, applies reply transformers, and emits Pub/Sub or monitor events when relevant.\n\n## Commit Messages\n\nFollow [Conventional Commits](https://www.conventionalcommits.org/): `<type>: <subject>`.\n\nCommon types include `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, and `chore`.\n\nReleases are automated via semantic-release (`.releaserc.json`), so commit messages drive the changelog and version bump.\n"},"items":[{"name":"AGENTS.md","path":"AGENTS.md","title":"AGENTS.md","content":"# AGENTS.md\n\nThis file provides guidance to AI coding agents (Claude Code, Codex, Copilot, Cursor, Aider, etc.) when working with code in this repository.\n\n## Project Overview\n\nioredis is a full-featured Redis client for Node.js, written 100% in TypeScript. Source lives in `lib/`, compiles to CommonJS in `built/` (the published artifact), and supports standalone, Sentinel, and Cluster topologies.\n\n## Common Commands\n\n### Building\n\n```bash\nnpm run build          # Wipe built/ and compile TypeScript\nnode bin/index.js      # Regenerate lib/utils/RedisCommander.ts\n```\n\n### Linting and Formatting\n\n```bash\nnpm run lint           # Run ESLint over lib/\nnpm run format         # Format files with Prettier\nnpm run format-check   # Check formatting\n```\n\n### Testing\n\nFunctional and cluster tests require running Redis servers. Unit tests under `test/unit/` mock the network and do not need a server.\n\nTo start and stop local Redis test infrastructure:\n\n```bash\nnpm run docker:setup      # Start standalone Redis on 6379 and cluster nodes on 3000-3005\nnpm run docker:teardown   # Stop test Redis servers\n```\n\n```bash\nnpm test                  # Default non-cluster test: test:js then test:tsd\nnpm run test:js           # Mocha over test/helpers, test/unit, test/functional\nnpm run test:cluster      # Mocha over test/cluster\nnpm run test:tsd          # Build then run tsd against test/typing\nnpm run test:cov          # Test coverage\n\n# Run a single test file\nTS_NODE_TRANSPILE_ONLY=true NODE_ENV=test npx mocha --no-experimental-strip-types \"test/unit/foo.ts\"\n\n# Run a single test by name\nTS_NODE_TRANSPILE_ONLY=true NODE_ENV=test npx mocha --no-experimental-strip-types \"test/unit/foo.ts\" --grep \"partial test title\"\n```\n\n## Generated Code\n\n**Do not hand-edit**: `lib/utils/RedisCommander.ts` (generated), `built/` (build output), and `node_modules/`.\n\n`lib/utils/RedisCommander.ts` holds the typed signatures for every Redis command. This is what gives calls like `redis.set(...)` their types.\n\nRegenerate it with:\n\n```bash\nnode bin/index.js\n```\n\nGeneration uses `@ioredis/interface-generator` plus per-command config in `bin/`:\n\n- **`bin/template.ts`** — File skeleton; generated interface is spliced into the `////` marker.\n- **`bin/overrides.js`** — Hand-written signatures for commands the generator gets wrong, such as `hgetall` and `mset`.\n- **`bin/argumentTypes.js`**, **`bin/returnTypes.js`**, **`bin/sortArguments.js`**, **`bin/typeMaps.js`** — Argument and return type mapping and ordering.\n\nWhen adding command typing support, edit the `bin/` config and regenerate. Never patch `RedisCommander.ts` directly.\n\n## Architecture\n\n### Layered Design\n\n```text\nPublic API (`Redis`, `Cluster`, `Pipeline`, `Command`, options)\n  → Command facade (`Commander`, generated `RedisCommander` typings, Lua scripts)\n    → Command objects and queues (`Command`, offline queue, command queue, pipeline queue)\n      → Topology routing (standalone, Sentinel, Cluster slots, subscriber groups)\n        → Connection layer (`connectors/`, `redis/event_handler.ts`, retry and ready checks)\n          → RESP parsing and reply handling (`DataHandler`, `redis-parser`)\n```\n\n### Key Source Areas\n\n- **`lib/index.ts`** — Public export surface for the package. Changes here affect the published TypeScript declarations and user-facing API.\n- **`lib/Redis.ts`** — Main standalone and Sentinel client. Manages connection lifecycle (`wait → connecting → connect → ready → close → reconnecting → end`), offline queue behavior, reconnection strategy, and connector selection.\n- **`lib/utils/Commander.ts`** — Shared command facade for `Redis` and `Cluster`. Dynamically attaches builtin Redis commands, string and `Buffer` variants, autopipelining dispatch, direct `sendCommand`, and `defineCommand` Lua registration.\n- **`lib/Command.ts`** — Single Redis command representation. Handles argument transformation, reply transformation, promise/callback resolution, key-slot calculation, and subscriber/monitor-mode command flags.\n- **`lib/DataHandler.ts`** — Parser and reply dispatcher. Wraps `redis-parser`, consumes socket data, resolves queued commands, and routes Pub/Sub replies and monitor messages.\n- **`lib/connectors/`** — Network connector implementations. `StandaloneConnector` handles TCP/TLS sockets; `SentinelConnector/` resolves masters through Sentinel using `FailoverDetector` and `SentinelIterator`.\n- **`lib/cluster/`** — Cluster client, per-node connection pool, slot cache refresh, redirection handling for `MOVED` and `ASK`, retry scheduling, and cluster Pub/Sub through `ClusterSubscriber`, `ShardedSubscriber`, and `ClusterSubscriberGroup`.\n- **`lib/Pipeline.ts`** and **`lib/transaction.ts`** — Batched command execution. `pipeline()` is non-atomic batching; `multi()` adds MULTI/EXEC transaction behavior.\n- **`lib/autoPipelining.ts`** — Same-tick command batching. `notAllowedAutoPipelineCommands` lists commands that must bypass autopipelining, such as auth, subscribe, and multi.\n- **`lib/Script.ts`** — Lua script abstraction used by `defineCommand`, with `EVALSHA` execution and `EVAL` fallback.\n- **`lib/ScanStream.ts`** — Readable stream wrapper for `SCAN`, `HSCAN`, `SSCAN`, and `ZSCAN`.\n- **`lib/tracing.ts`** — Command and connection tracing hooks with argument sanitization.\n\n### How Commands Execute\n\n1. User calls a method such as `redis.get()` or `cluster.set()`.\n2. `Commander` routes the call through autopipelining, pipeline/transaction handling, or direct `sendCommand`.\n3. A `Command` object is created with transformed arguments and callback/promise state.\n4. Standalone clients enqueue the command on one connection; Cluster clients choose a node by key slot and may retry on redirects.\n5. The command is written to the socket after connection readiness checks and offline queue handling.\n6. `redis-parser` parses the RESP reply from the socket.\n7. `DataHandler` resolves the matching queued command, applies reply transformers, and emits Pub/Sub or monitor events when relevant.\n\n## Commit Messages\n\nFollow [Conventional Commits](https://www.conventionalcommits.org/): `<type>: <subject>`.\n\nCommon types include `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, and `chore`.\n\nReleases are automated via semantic-release (`.releaserc.json`), so commit messages drive the changelog and version bump.\n","category":"root","tokens":1584}]}