redis
GitHub提供 Redis 单机、集群及哨兵模式的命令执行能力,涵盖语法、作用域路由及配置说明。支持跨节点扫描与自动认证,禁止使用 SELECT 命令,适用于各类 Redis 操作场景。
触发场景
安装
npx skills add opskat/opskat --skill redis -g -y
SKILL.md
Frontmatter
{
"name": "redis",
"description": "Run Redis commands against a Redis asset (standalone, cluster or sentinel) via exec. Covers command syntax, what scope means in each mode (db number or cluster node), cluster command routing, and why SELECT must not be used."
}
Redis assets
Command syntax
Pass the Redis command verbatim as command:
GET mykeyHGETALL user:1SET key value EX 3600SCAN 0 MATCH prefix:* COUNT 100
Scope
A Redis asset runs in one of three modes (mode in its config); scope means
something different in each.
Standalone and sentinel — scope is the database number (0-15), e.g.
scope: "3". Omit it to use the asset's configured database. In sentinel mode
every command goes to the master the sentinels currently report.
Cluster — a cluster has only db0; scope is a node address host:port.
Each command is routed as follows:
- Commands that name keys (
GET,HGETALL,SET, …) are routed to the master that owns the key's slot;scopeis ignored. Multi-key commands whose keys hash to different slots fail with Redis'sCROSSSLOTerror — use hash tags ({user:1}:a,{user:1}:b) or run them one key at a time. PING,ECHO,TIME,COMMAND …andCLUSTER INFO|NODES|SLOTS|SHARDS|KEYSLOTrun on any reachable node whenscopeis omitted (or on thescopenode when given). OtherCLUSTERsubcommands act on one node (COUNTKEYSINSLOT,RESET,FORGET,FAILOVER, …) and needscopelike rule 3.- Every other keyless command (
SCAN,KEYS,DBSIZE,INFO,CONFIG GET,FLUSHDB, …) only sees one node's data, so it requiresscopeset to a node, e.g.scope: "10.0.0.2:7002". Without it (or with a db number / unknown address) the call fails and the error lists the current master addresses — pick one and retry, once per master if you need the whole cluster. A replica address is accepted too (useful for read-only diagnostics).
Cluster results carry node (the node that executed the command) and route
(key, scope or any) so you can tell how much of the cluster a result covers.
Do NOT send SELECT. It is rejected outright before execution — connections
are pooled, so a per-connection database switch would corrupt another caller's
selection; a cluster has only db0 anyway. scope is the only correct way to
switch databases.
Notes
- Results are returned as JSON.
- Credentials are resolved automatically from the app's encrypted store; never ask the user for a password.
Asset config (for put_asset)
| field | type | required | notes |
|---|---|---|---|
mode |
string | no | standalone (default), cluster or sentinel |
host |
string | standalone | Standalone only |
port |
number | no | Standalone only. Defaults to 6379 |
nodes |
string[] | cluster, sentinel | host:port list: cluster seed nodes, or the sentinel nodes |
master_name |
string | sentinel | Name of the master group monitored by the sentinels |
username |
string | yes | Data-node user. Use "default" for Redis's built-in default user |
password |
string | no | Write-only. Data-node password, encrypted in the asset; does not create a credential |
credential_id |
number | no | Existing managed password credential ID |
sentinel_username |
string | no | Sentinel only, when the sentinels themselves require auth |
sentinel_password |
string | no | Sentinel only. Write-only. Encrypted in the asset; managed credentials are not supported |
redis_db |
number | no | Default DB index (0-15). Standalone and sentinel; must be 0 in cluster mode |
node_address_map |
object | no | Cluster and sentinel. Maps announced host:port → actual host:port to dial, for nodes that announce addresses unreachable from here (e.g. Docker bridge IPs) |
ssh_asset_id |
number | no | SSH asset to tunnel through; 0 detaches. Applies to every node connection |
Only the fields of the chosen mode are stored. password and credential_id are
mutually exclusive. Plaintext is never returned, is encrypted in the asset, and never
creates a managed credential.
版本历史
-
25146f5
当前 2026-09-27 21:12
新增 Redis 集群和哨兵模式支持,完善多部署模式下的命令路由、作用域处理及资产配置字段。
-
b159e91
2026-08-19 20:21
更新端口默认值说明为显式传递;username 字段增加对无 ACL 旧版 Redis 的说明;密码存储描述简化。
-
d6c7a6e
2026-08-16 07:29
修正文档:明确 SELECT 命令在连接池模式下会被直接拒绝,而非无效或导致串库风险。
- aeb4bc3 2026-07-24 16:28


