Skip to content
FunCoding

Search

Search docs, Skills and MCP

redis-safety

当用户操作 Redis 相关代码(go-redis、Jedis、redis-py、ioredis)时触发。涵盖禁止 KEYS 命令、SCAN 替代、大 key 控制、Pipeline 批量、TTL 规范等安全与性能要点。

数据库与数据1.1k.antigravity/skills/redis-safety/SKILL.md

Install

Send this to Claude Code, Codex or Cursor. The agent checks the Skill for safety first and installs it only after you confirm.

读取 https://funcoding.ai/skills/doccker/cc-use-exp/antigravity-skills-redis-safety/install.md ,按里面的步骤帮我安装这个 Skill。

SKILL.md

Redis 安全规范

防止 Redis 常见性能和稳定性问题,适用于所有语言。


禁止操作

禁止替代原因
KEYS * / KEYS patternSCAN 游标迭代KEYS 是 O(N) 阻塞操作,生产环境会导致 Redis 卡死
FLUSHDB / FLUSHALL按 key 前缀 SCAN + DEL全量删除风险极高
无 TTL 的 SET所有 key 必须设置 TTL避免内存泄漏

必须遵守

1. 用 SCAN 替代 KEYS

// Go (go-redis) ❌
keys, _ := rdb.Keys(ctx, "user:*").Result()

// Go (go-redis) ✅
var cursor uint64
for {
    keys, cursor, _ = rdb.Scan(ctx, cursor, "user:*", 100).Result()
    // 处理 keys
    if cursor == 0 { break }
}
// Java (Jedis) ❌
Set<String> keys = jedis.keys("user:*");

// Java (Jedis) ✅
ScanParams params = new ScanParams().match("user:*").count(100);
String cursor = "0";
do {
    ScanResult<String> result = jedis.scan(cursor, params);
    // 处理 result.getResult()
    cursor = result.getCursor();
} while (!cursor.equals("0"));
# Python (redis-py) ❌
keys = r.keys("user:*")

# Python (redis-py) ✅
for key in r.scan_iter(match="user:*", count=100):
    # 处理 key

2. 大 key 控制

  • 单个 key 的 value 不超过 10KB
  • 集合类型(List/Set/Hash/ZSet)元素不超过 5000 个
  • 超过时拆分为多个 key

3. Pipeline 批量操作

多次 Redis 调用应使用 Pipeline 减少网络往返:

// ❌ 循环单次调用
for _, id := range ids {
    rdb.Get(ctx, "user:"+id)
}

// ✅ Pipeline 批量
pipe := rdb.Pipeline()
for _, id := range ids {
    pipe.Get(ctx, "user:"+id)
}
pipe.Exec(ctx)

4. 所有 key 设置 TTL

// ❌
rdb.Set(ctx, "token:123", value, 0)

// ✅
rdb.Set(ctx, "token:123", value, 24*time.Hour)

Similar Skills

xlsx
anthropics/skills180k

xlsx

Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.

Databases & data

deprecation-and-migration
addyosmani/agent-skills103k

deprecation-and-migration

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.

Databases & data

host-observer
thedotmack/claude-mem98k

host-observer

Use this when fulfilling claude-mem observer jobs on Grok Bot: reply only skip_summary or one full observation XML, never prose.

Databases & data

babysit
thedotmack/claude-mem98k

babysit

Watch a pull request or review cycle until it is ready to merge. Use when asked to babysit, monitor, or keep checking PR comments, reviews, and CI until all actionable issues are resolved.

Databases & data

mem-search
thedotmack/claude-mem98k

mem-search

Search claude-mem's persistent cross-session memory database. Use when user asks "did we already solve this?", "how did we do X last time?", or needs work from previous sessions.

Databases & data

Agent Cost Report
thedotmack/claude-mem98k

Agent Cost Report

Believable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.

Databases & data