Agent skill

Python Redis Module Skill

by jiushiwon in jiushiwon/wg-skills

Python Redis 模块快速集成技能。面向已拥有 FastAPI 项目骨架的开发者,提供 Redis 缓存、Session 存储、分布式锁、限流、消息队列等能力的快速集成。触发词:"Python Redis"、"FastAPI Redis"、"Redis 集成"、"redis cache"、"redis session"、"redis lock"、"redis 限流"、"redis…

Apache-2.0Auto-check: notesDatabases

Install Python Redis Module Skill

skills CLI
$ npx skills add jiushiwon/wg-skills --skill python-redis-module-skill -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jiushiwon/wg-skills python-redis-module-skill --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jiushiwon/wg-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/vibeCoding/backend/python/fastapi-module/python-redis-module-skill .claude/skills/python-redis-module-skill && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
python-redis-module-skill
GitHub stars
110
Token cost
~1.7k tokens
SKILL.md length
61 words
Files
2
Skills in repo
121
Repo updated
First seen
Licence
Apache-2.0

At a glance

Python Redis 模块快速集成技能。面向已拥有 FastAPI 项目骨架的开发者,提供 Redis 缓存、Session 存储、分布式锁、限流、消息队列等能力的快速集成。触发词:"Python Redis"、"FastAPI Redis"、"Redis 集成"、"redis cache"、"redis session"、"redis lock"、"redis 限流"、"redis…

  • Works in 5 steps: Redis 客户端 → 缓存装饰器 → 分布式锁 → …
  • Tasks that involve Backend development
  • SKILL.md covers 能力清单, 触发场景, 依赖配置 and 默认方法封装, plus 2 more sections
  • Calls pip; needs REDIS_PASSWORD

What it does

Python Redis Module Skill is an agent skill from jiushiwon/wg-skills. Python Redis 模块快速集成技能。面向已拥有 FastAPI 项目骨架的开发者,提供 Redis 缓存、Session 存储、分布式锁、限流、消息队列等能力的快速集成。触发词:"Python Redis"、"FastAPI Redis"、"Redis 集成"、"redis cache"、"redis session"、"redis lock"、"redis 限流"、"redis 消息队列"。

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `README.md`).

It sits in Databases, covering Backend development and Caching. It works with Redis, Python and FastAPI. The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Backend development
  • Tasks that involve Caching

Example prompts

  • “Python Redis”
  • “FastAPI Redis”
  • “Redis 集成”
  • “/python-redis-module-skill”

Requirements

  • Python 3
  • Docker

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Redis 客户端
  2. 缓存装饰器
  3. 分布式锁
  4. 限流
  5. 消息队列(Stream)

What it can do on your machine

Read from SKILL.md and the folder at commit a4a640b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pip

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pip, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • REDIS_PASSWORD

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Python Redis Module Skill loads about 1.7k tokens when it runs. Until then it costs about 57 tokens; SKILL.md has 61 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~57
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:251
    ### .env

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jiushiwon/wg-skills at commit a4a640b, republished under its Apache-2.0 licence (© jiushiwon). 61 words, ~1,723 tokens.

Download SKILL.mdSave it as .claude/skills/python-redis-module-skill/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
python-redis-module-skill
description
Python Redis 模块快速集成技能。面向已拥有 FastAPI 项目骨架的开发者,提供 Redis 缓存、Session 存储、分布式锁、限流、消息队列等能力的快速集成。触发词:"Python Redis"、"FastAPI Redis"、"Redis 集成"、"redis cache"、"redis session"、"redis lock"、"redis 限流"、"redis 消息队列"。

Python Redis Module Skill

面向已有 FastAPI 项目的开发者,快速集成 Redis 能力。

能力清单

能力说明
缓存装饰器缓存、缓存更新、缓存删除
SessionRedis Session 共享
分布式锁基于 Redis 的分布式锁
限流基于 Redis 的接口限流
消息队列Redis Stream 消息发布/订阅
计数器分布式计数器

触发场景

用户说"帮我加 Redis"或"集成 Redis"时触发。

依赖配置

bash
pip install redis aioredis

默认方法封装

1. Redis 客户端
python
# redis_client.py
import redis
from typing import Optional

class RedisClient:
    def __init__(self, host: str = "localhost", port: int = 6379, password: Optional[str] = None, db: int = 0):
        self.client = redis.Redis(
            host=host,
            port=port,
            password=password,
            db=db,
            decode_responses=True
        )
    
    # 基础操作
    def get(self, key: str) -> Optional[str]:
        return self.client.get(key)
    
    def set(self, key: str, value: str, ex: Optional[int] = None) -> bool:
        return self.client.set(key, value, ex=ex)
    
    def delete(self, *keys: str) -> int:
        return self.client.delete(*keys)
    
    def exists(self, key: str) -> bool:
        return self.client.exists(key)
    
    def expire(self, key: str, seconds: int) -> bool:
        return self.client.expire(key, seconds)
    
    # 哈希操作
    def hget(self, name: str, key: str) -> Optional[str]:
        return self.client.hget(name, key)
    
    def hset(self, name: str, key: str, value: str) -> int:
        return self.client.hset(name, key, value)
    
    def hgetall(self, name: str) -> dict:
        return self.client.hgetall(name)
    
    # 列表操作
    def lpush(self, name: str, *values: str) -> int:
        return self.client.lpush(name, *values)
    
    def rpop(self, name: str) -> Optional[str]:
        return self.client.rpop(name)
    
    # 自增
    def incr(self, key: str, amount: int = 1) -> int:
        return self.client.incr(key, amount)
    
    # 分布式锁
    def lock(self, key: str, timeout: int = 30) -> bool:
        return self.client.set(f"lock:{key}", "1", nx=True, ex=timeout)
    
    def unlock(self, key: str) -> int:
        return self.client.delete(f"lock:{key}")

# 全局实例
redis_client = RedisClient()
2. 缓存装饰器
python
# cache.py
import json
import functools
from typing import Callable, Optional, Any

def cache(key_prefix: str, expire: int = 300):
    """缓存装饰器"""
    def decorator(func: Callable) -> Callable:
        @functools.wraps(func)
        async def wrapper(*args, **kwargs) -> Any:
            # 生成缓存 key
            cache_key = f"{key_prefix}:{':'.join(str(a) for a in args)}"
            
            # 尝试从缓存获取
            cached = redis_client.get(cache_key)
            if cached:
                return json.loads(cached)
            
            # 执行函数
            result = await func(*args, **kwargs)
            
            # 存入缓存
            redis_client.set(cache_key, json.dumps(result, ensure_ascii=False), ex=expire)
            return result
        return wrapper
    return decorator

# 使用示例
@cache("user:info", expire=600)
async def get_user(user_id: int):
    # 首次查询数据库,之后从缓存取
    return await db.query_user(user_id)
3. 分布式锁
python
# lock.py
import asyncio
from contextlib import asynccontextmanager
from typing import Optional

class RedisLock:
    def __init__(self, client: RedisClient):
        self.client = client
    
    @asynccontextmanager
    async def lock(self, key: str, timeout: int = 30, retry: int = 3, delay: float = 0.2):
        """分布式锁上下文管理器"""
        lock_key = f"lock:{key}"
        
        for _ in range(retry):
            if self.client.client.set(lock_key, "1", nx=True, ex=timeout):
                try:
                    yield True
                finally:
                    self.client.client.delete(lock_key)
                return
            await asyncio.sleep(delay)
        
        raise TimeoutError(f"获取锁 {key} 失败")

# 使用
lock = RedisLock(redis_client)
async with lock.lock("order:create"):
    # 临界区代码
    pass
4. 限流
python
# rate_limit.py
import time
from typing import Optional

class RateLimiter:
    def __init__(self, client: RedisClient):
        self.client = client
    
    def try_acquire(self, key: str, max_requests: int, window_seconds: int = 60) -> bool:
        """滑动窗口限流"""
        now = time.time()
        window_key = f"ratelimit:{key}"
        
        # 移除过期的请求记录
        self.client.client.zremrangebyscore(window_key, 0, now - window_seconds)
        
        # 当前请求数
        current = self.client.client.zcard(window_key)
        
        if current >= max_requests:
            return False
        
        # 添加当前请求
        self.client.client.zadd(window_key, {str(now): now})
        self.client.client.expire(window_key, window_seconds)
        return True

# 使用
limiter = RateLimiter(redis_client)

async def check_rate_limit(request_id: str) -> bool:
    if not limiter.try_acquire(f"api:{request_id}", 100, 60):
        raise Exception("请求过于频繁")
    return True
5. 消息队列(Stream)
python
# mq.py
import json
from typing import Callable, Dict, Any, Optional

class RedisStream:
    def __init__(self, client: RedisClient):
        self.client = client
    
    def publish(self, stream: str, data: Dict[str, Any]) -> str:
        """发布消息"""
        return self.client.client.xadd(stream, data)
    
    def subscribe(self, stream: str, group: str, consumer: str, count: int = 10, block: int = 5000):
        """订阅消息"""
        while True:
            messages = self.client.client.xread(
                {stream: "0"},
                count=count,
                block=block
            )
            if messages:
                for stream_name, msgs in messages:
                    for msg_id, msg_data in msgs:
                        yield msg_id, msg_data
                        # 确认消息
                        self.client.client.xack(stream, group, msg_id)

# 生产者
stream = RedisStream(redis_client)
stream.publish("notifications", {"user_id": "123", "message": "hello"})

# 消费者
async def consume_messages():
    async for msg_id, msg in stream.subscribe("notifications", "my-group", "consumer-1"):
        print(f"收到消息: {msg}")

配置模板

.env
env
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_DATABASE=0
config.py
python
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    redis_host: str = "localhost"
    redis_port: int = 6379
    redis_password: str = ""
    redis_database: int = 0

settings = Settings()

不做

  • 不负责安装 Redis(用户自行安装或使用 Docker)
  • 不处理 Redis 集群配置(单节点为主)
  • 不提供数据迁移工具
  • 不处理哨兵/主从配置

© jiushiwon, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in vibeCoding/backend/python/fastapi-module/python-redis-module-skill of jiushiwon/wg-skills.

  • SKILL.md
  • README.md

Open the folder on GitHubat commit a4a640b

Compare with similar skills

Python Redis Module Skill next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Python Redis Module Skill compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Python Redis Module Skill this skilljiushiwon/wg-skills110—~1.7kAutomated safety check: NotesApache-2.0
FastAPI-Redis SDK Developmentredis/fastapi-redis-sdk404—~2.5kAutomated safety check: NotesMIT
Flowfile Debugging PlaybookEdwardvaneechoud/Flowfile370—~6.3kAutomated safety check: PassMIT
Python PatternsxenitV1/Antigravity-Workflows1307 repos~2.2kAutomated safety check: PassMIT
Azure Cosmos DB Pymicrosoft/skills3.1k—~2.8kAutomated safety check: PassMIT
Supabase Pythonalinaqi/maggy707—~4kAutomated safety check: NotesMIT

Similar skills

  • FastAPI-Redis SDK Development

    redis/fastapi-redis-sdk

    Official

    Guides development on the fastapi-redis-sdk library itself - its connection lifecycle, dependency-injected caching, and async/sync bridging.

    404 GitHub stars~2.5k tokensUpdated 6 days ago
    Backend & APIsAuto-check: notes
  • Flowfile Debugging Playbook

    Edwardvaneechoud/Flowfile

    Symptom-to-cause triage playbook for Flowfile (core/worker/kernel/frontend/AI) — covers "no such table" DB cascades (two distinct causes), import-time Alembic migration corruption, silent…

    370 GitHub stars~6.3k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Python Patterns

    xenitV1/Antigravity-Workflows

    Python development principles and decision-making. An agent skill from xenitV1/Antigravity-Workflows.

    130 GitHub starsUsed in 7 repos~2.2k tokens
    Backend & APIsAuto-check passed
  • Azure Cosmos DB Py

    microsoft/skills

    Official

    Build Azure Cosmos DB NoSQL services with Python/FastAPI following production-grade patterns.

    3.1k GitHub stars~2.8k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Supabase Python

    alinaqi/maggy

    FastAPI with Supabase and SQLAlchemy/SQLModel. An agent skill from alinaqi/maggy.

    707 GitHub stars~4k tokensUpdated 13 days ago
    DatabasesAuto-check: notes
  • Fastcrud

    benavlabs/fastcrud

    A skill your agent uses when building or modifying CRUD endpoints with FastCRUD (the fastcrud PyPI package) in a FastAPI project — covers FastCRUD, crudrouter, EndpointCreator, FilterConfig…

    1.6k GitHub stars~5k tokensUpdated 13 days ago
    Backend & APIsAuto-check passed

More from jiushiwon/wg-skills

All 121 skills in this repo
  • Frontend UI Foundry

    jiushiwon/wg-skills

    A skill your agent uses when generating UI for a specific scenario (mobile/PC/官网/管理端/营销页/文档/金融/原生/3D), when refactoring an existing HTML/Vue/React project to a unified design system, when extracting…

    110 GitHub stars~1.4k tokensUpdated 3 days ago
    Auto-check passed
  • Workflow Diagram Skill

    jiushiwon/wg-skills

    A skill your agent uses when 用户想用一句话生成流程图、工作流图解、开发流程图、AI 流程图或任何步骤型图解,支持多风格输出(flat icon / 暖白手账风 / dark / cute),并提供现成模板一键出图。

    110 GitHub stars~1.2k tokensUpdated 3 days ago
    Auto-check passed
  • Uniapp App Generate Skill

    jiushiwon/wg-skills

    This skill should be used when the user wants to create a standardized uni-app project for WeChat mini-program, H5, and App from scratch.

    110 GitHub stars~5k tokensUpdated 3 days ago
    Auto-check: notes
  • Fastapi Init Skill

    jiushiwon/wg-skills

    FastAPI 项目一键初始化技能。面向零基础小白,提供环境探测、自动安装、完整 Web 骨架生成、SSE 流式框架、JWT 鉴权、统一响应封装、文件上传接口、一键启动/重启脚本、Swagger 文档,内置 MySQL(默认)/ PostgreSQL / MongoDB 数据库选择。用户只需说"帮我搭一个 FastAPI 项目"即可一条命令完成从零到跑的完整链路。触发词:"FastAPI…

    110 GitHub stars~1.8k tokensUpdated 3 days ago
    Auto-check: notes
  • Ffmpeg Skill

    jiushiwon/wg-skills

    FFmpeg 多媒体处理技能 — 将自然语言描述转为正确的 ffmpeg 命令,覆盖视频剪辑、转码、水印、合成、提取、生成等操作。内置一键安装脚本(Windows/Mac/Linux)。触发词:ffmpeg、视频剪辑、视频裁剪、视频转码、视频压缩、去水印、加水印、视频拼接、视频合成、提取音频、视频转…

    110 GitHub stars~1.4k tokensUpdated 3 days ago
    Auto-check passed
  • Frontend Request Skill

    jiushiwon/wg-skills

    A skill your agent uses when designing or reviewing the request layer of a frontend project (web / uni-app / mini-program), including request.ts wrappers, interceptors, deduplication, mocks, error…

    110 GitHub stars~3.6k tokensUpdated 3 days ago
    Auto-check passed

Questions about Python Redis Module Skill

What does Python Redis Module Skill do?

Python Redis 模块快速集成技能。面向已拥有 FastAPI 项目骨架的开发者,提供 Redis 缓存、Session 存储、分布式锁、限流、消息队列等能力的快速集成。触发词:"Python Redis"、"FastAPI Redis"、"Redis 集成"、"redis cache"、"redis session"、"redis lock"、"redis 限流"、"redis…. Python Redis Module Skill is an agent skill from jiushiwon/wg-skills.

When should I use Python Redis Module Skill?

Python Redis Module Skill fits situations like: tasks that involve Backend development; tasks that involve Caching.

How do I install Python Redis Module Skill in Claude Code?

Run `npx skills add jiushiwon/wg-skills --skill python-redis-module-skill -a claude-code`. Or copy the skill folder (vibeCoding/backend/python/fastapi-module/python-redis-module-skill in jiushiwon/wg-skills) into .claude/skills/python-redis-module-skill in your project. Claude Code loads it when a task matches its description.

How do I install Python Redis Module Skill in Codex?

Run `npx skills add jiushiwon/wg-skills --skill python-redis-module-skill -a codex`. Or copy the skill folder (vibeCoding/backend/python/fastapi-module/python-redis-module-skill in jiushiwon/wg-skills) into .agents/skills/python-redis-module-skill in your project. Codex loads it when a task matches its description.

Can I use Python Redis Module Skill in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jiushiwon/wg-skills --skill python-redis-module-skill -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/python-redis-module-skill, .gemini/skills/python-redis-module-skill, .github/skills/python-redis-module-skill and .opencode/skills/python-redis-module-skill in your project.

What does Python Redis Module Skill need to run?

Going by SKILL.md and its folder, Python Redis Module Skill needs the command-line tools its instructions call (pip) and credentials named REDIS_PASSWORD. Our summary lists: Python 3; Docker.

Does Python Redis Module Skill access the network?

SKILL.md contains no URLs. Its commands use pip, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Python Redis Module Skill safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Python Redis Module Skill use?

Python Redis Module Skill is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Python Redis Module Skill use?

About 1.7k tokens (SKILL.md is roughly 6.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Python Redis Module Skill?

Skills that share tags, products or a category with Python Redis Module Skill: FastAPI-Redis SDK Development (redis/fastapi-redis-sdk, 404 stars), Flowfile Debugging Playbook (Edwardvaneechoud/Flowfile, 370 stars), Python Patterns (xenitV1/Antigravity-Workflows, 130 stars) and Azure Cosmos DB Py (microsoft/skills, 3.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Python Redis Module Skill?

jiushiwon (a GitHub user) maintains it in jiushiwon/wg-skills, which has 110 GitHub stars. The repository holds 121 skills in this directory. The repository was last updated on October 4, 2026.

Source: jiushiwon/wg-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.