Agent Skills › opskat/opskat › redis

redis

GitHub

提供 Redis 单机、集群及哨兵模式的命令执行能力,涵盖语法、作用域路由及配置说明。支持跨节点扫描与自动认证,禁止使用 SELECT 命令,适用于各类 Redis 操作场景。

internal/ai/skills/redis/SKILL.md opskat/opskat

触发场景

需要执行 Redis 命令 查询或修改 Redis 数据 管理 Redis 集群/哨兵节点

安装

npx skills add opskat/opskat --skill redis -g -y
更多选项

非标准路径

npx skills add https://github.com/opskat/opskat/tree/main/internal/ai/skills/redis -g -y

不安装直接使用

npx skills use opskat/opskat@redis

指定 Agent (Claude Code)

npx skills add opskat/opskat --skill redis -a claude-code -g -y

安装 repo 全部 skill

npx skills add opskat/opskat --all -g -y

预览 repo 内 skill

npx skills add opskat/opskat --list

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 mykey
  • HGETALL user:1
  • SET key value EX 3600
  • SCAN 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:

  1. Commands that name keys (GET, HGETALL, SET, …) are routed to the master that owns the key's slot; scope is ignored. Multi-key commands whose keys hash to different slots fail with Redis's CROSSSLOT error — use hash tags ({user:1}:a, {user:1}:b) or run them one key at a time.
  2. PING, ECHO, TIME, COMMAND … and CLUSTER INFO|NODES|SLOTS|SHARDS|KEYSLOT run on any reachable node when scope is omitted (or on the scope node when given). Other CLUSTER subcommands act on one node (COUNTKEYSINSLOT, RESET, FORGET, FAILOVER, …) and need scope like rule 3.
  3. Every other keyless command (SCAN, KEYS, DBSIZE, INFO, CONFIG GET, FLUSHDB, …) only sees one node's data, so it requires scope set 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

同 Skill 集合

internal/ai/skills/database/SKILL.md
internal/ai/skills/etcd/SKILL.md
internal/ai/skills/k8s/SKILL.md
internal/ai/skills/kafka/SKILL.md
internal/ai/skills/local/SKILL.md
internal/ai/skills/mongodb/SKILL.md
internal/ai/skills/oss/SKILL.md
internal/ai/skills/rdp/SKILL.md
internal/ai/skills/serial/SKILL.md
internal/ai/skills/ssh/SKILL.md
internal/ai/skills/vnc/SKILL.md
plugin/opsctl/skills/opsctl/SKILL.md

元信息

文件数
0
版本
25146f5
Hash
d90d3e35
收录时间
2026-07-24 16:28

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-28 02:25
浙ICP备14020137号-1