Python Redis Module Skill
jiushiwon/wg-skills
Python Redis 模块快速集成技能。面向已拥有 FastAPI 项目骨架的开发者,提供 Redis 缓存、Session 存储、分布式锁、限流、消息队列等能力的快速集成。触发词:"Python Redis"、"FastAPI Redis"、"Redis 集成"、"redis cache"、"redis session"、"redis lock"、"redis 限流"、"redis…
Guides development on the fastapi-redis-sdk library itself - its connection lifecycle, dependency-injected caching, and async/sync bridging.
$ npx skills add redis/fastapi-redis-sdk --skill fastapi-redis-sdk -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install redis/fastapi-redis-sdk fastapi-redis-sdk --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/redis/fastapi-redis-sdk.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/skills/redis-fastapi .claude/skills/fastapi-redis-sdk && rm -rf skills-srcUse ~/.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/
Install the "fastapi-redis-sdk" agent skill from https://github.com/redis/fastapi-redis-sdk/tree/main/.github/skills/redis-fastapi into .claude/skills/fastapi-redis-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "fastapi-redis-sdk", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/redis/fastapi-redis-sdk/tree/main/.github/skills/redis-fastapiType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add redis/fastapi-redis-sdk --skill fastapi-redis-sdk -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install redis/fastapi-redis-sdk fastapi-redis-sdk --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/redis/fastapi-redis-sdk.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.github/skills/redis-fastapi .agents/skills/fastapi-redis-sdk && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "fastapi-redis-sdk" agent skill from https://github.com/redis/fastapi-redis-sdk/tree/main/.github/skills/redis-fastapi into .agents/skills/fastapi-redis-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "fastapi-redis-sdk", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add redis/fastapi-redis-sdk --skill fastapi-redis-sdk -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install redis/fastapi-redis-sdk fastapi-redis-sdk --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/redis/fastapi-redis-sdk.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.github/skills/redis-fastapi .cursor/skills/fastapi-redis-sdk && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "fastapi-redis-sdk" agent skill from https://github.com/redis/fastapi-redis-sdk/tree/main/.github/skills/redis-fastapi into .cursor/skills/fastapi-redis-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "fastapi-redis-sdk", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/redis/fastapi-redis-sdk.git --path .github/skills/redis-fastapi--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add redis/fastapi-redis-sdk --skill fastapi-redis-sdk -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install redis/fastapi-redis-sdk fastapi-redis-sdk --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/redis/fastapi-redis-sdk.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.github/skills/redis-fastapi .gemini/skills/fastapi-redis-sdk && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "fastapi-redis-sdk" agent skill from https://github.com/redis/fastapi-redis-sdk/tree/main/.github/skills/redis-fastapi into .gemini/skills/fastapi-redis-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "fastapi-redis-sdk", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install redis/fastapi-redis-sdk fastapi-redis-sdkInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add redis/fastapi-redis-sdk --skill fastapi-redis-sdk -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/redis/fastapi-redis-sdk.git skills-src && mkdir -p .github/skills && cp -r skills-src/.github/skills/redis-fastapi .github/skills/fastapi-redis-sdk && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "fastapi-redis-sdk" agent skill from https://github.com/redis/fastapi-redis-sdk/tree/main/.github/skills/redis-fastapi into .github/skills/fastapi-redis-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "fastapi-redis-sdk", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add redis/fastapi-redis-sdk --skill fastapi-redis-sdk -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install redis/fastapi-redis-sdk fastapi-redis-sdk --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/redis/fastapi-redis-sdk.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.github/skills/redis-fastapi .opencode/skills/fastapi-redis-sdk && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "fastapi-redis-sdk" agent skill from https://github.com/redis/fastapi-redis-sdk/tree/main/.github/skills/redis-fastapi into .opencode/skills/fastapi-redis-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "fastapi-redis-sdk", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
fastapi-redis-sdkGuides development on the fastapi-redis-sdk library itself - its connection lifecycle, dependency-injected caching, and async/sync bridging.
This skill is scoped to writing code, tests or configuration for the fastapi-redis-sdk library, the official Redis integration for FastAPI, not general Redis or FastAPI questions. It lays out the project's layout, its uv and nox tooling for installing dependencies and running checks locally, and a hard architecture rule: Redis pools must be initialized through the app's lifespan, since accessing the pool without one raises a runtime error.
It covers the library's async-first design, where every dependency-injection factory is async and a sync cache backend bridges async calls for sync endpoints, plus two caching patterns built on the same connection pool: dependency-based cache, evict and put helpers with automatic HTTP caching semantics like ETag and 304 responses for GET requests only, and a lower-level backend object with get, set, delete, has and delete-group methods for conditional logic and cascading invalidation.
It also notes that the lifespan helper wraps rather than replaces an app's existing lifespan, and points to the library's own architecture docs for the details of that wrapping behavior.
2 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit ed7a579. It shows what the files ask for, not the result of running them.
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.
Shell commands in SKILL.md call:
uvFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use uv, which can reach the network depending on how they are called.
From URLs in SKILL.md, links to its own repository left out.
Names these keys or tokens, usually read from environment variables:
REDIS_PASSWORDFrom names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
FastAPI-Redis SDK Development loads about 2.5k tokens when it runs. Until then it costs about 100 tokens; SKILL.md has 846 words of instructions outside code blocks.
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.
The automated check noted patterns worth knowing about, such as sudo or a known installer.
tings via env vars prefixed `REDIS_` or `.env` file.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.
The full file from redis/fastapi-redis-sdk at commit ed7a579, republished under its MIT licence (© redis). 846 words, ~2,458 tokens.
.claude/skills/fastapi-redis-sdk/SKILL.md (or your agent's skills folder).Official Redis integration for FastAPI — connection management and DI-based caching with automatic key consistency.
src/redis_fastapi/ # Library source (single flat package)
__init__.py # Public API re-exports
setup.py # FastAPIRedis fluent builder
lifespan.py # redis_lifespan async context manager
deps.py # FastAPI DI factories & type aliases
config.py # RedisSettings (pydantic-settings)
cache.py # cache(), cache_evict(), cache_put() + middleware
cache_backend.py # CacheBackend (async) + SyncCacheBackend
telemetry.py # Optional OpenTelemetry instrumentation
types.py # Coder, KeyBuilder protocols
tests/
unit/ # fakeredis-based, no real Redis needed
integration/ # Requires Redis on localhost:6379
pyproject.toml # uv build backend, dependency groups, tool config
noxfile.py # CI-mirroring sessions (lint, typecheck, security, tests, docs)Package manager: uv. Task runner: nox (with uv venv backend).
uv sync --all-groups # Install all deps
uv run nox # Run ALL CI checks locally
uv run nox -s lint # Lint + format check only
uv run nox -s typecheck # mypy
uv run nox -s tests-3.12 # Full suite on a specific Python version
uv run nox -s tests_unit-3.12 # Unit suite only (fakeredis, no server)
uv run nox -s tests_integration-3.12 # Integration suite only (needs Redis)
uv run nox -s fix # Auto-fix lint/format
uv run nox -s docs_serve # Live-reload docs at localhost:8000Redis pools MUST be initialised via the app lifespan. There is no fallback.
Accessing the pool without a lifespan raises RuntimeError.
app = FastAPI()
FastAPIRedis(app).lifespan().caching() # Always call .lifespan()get_async_redis, get_cache_backend) are async.SyncCacheBackend wraps async calls via anyio.from_thread.run —
use only from sync endpoints running in FastAPI's worker threads.from redis_fastapi import AsyncRedisDep, CacheBackendDep, SyncCacheBackendDep
# Async endpoint — use AsyncRedisDep or CacheBackendDep
async def endpoint(redis: AsyncRedisDep): ...
async def endpoint(cache: CacheBackendDep): ...
# Sync endpoint — use SyncCacheBackendDep
def endpoint(cache: SyncCacheBackendDep): ....lifespan() wraps the app's existing lifespan — it does not replace it.
Multiple builder calls nest around whatever is already there. For explicit
ordering, skip .lifespan() and compose manually with redis_lifespan:
from redis_fastapi import FastAPIRedis, redis_lifespan
@asynccontextmanager
async def my_lifespan(app):
async with redis_lifespan(app):
async with db_lifespan(app):
yield
app = FastAPI(lifespan=my_lifespan)
FastAPIRedis(app).caching() # no .lifespan() — user owns itSee docs/guide/architecture.md § Lifespan wrapping for details.
Two patterns, same pool:
cache(ttl=N, eviction_group="x"), cache_evict(...),
cache_put(...) as Depends(). Requires .caching() on setup.get/set/delete/has/delete_group.
For conditional logic, cascade invalidation, dynamic TTL.timedelta for TTL (DI factories accept int seconds only).Choose cache() for most GET endpoints. Choose CacheBackend when you
need conditional caching, multi-step invalidation, or custom serializers.
cache_evict()/cache_put() bridge writes back to the same cache keys.
CacheHitException → exception handler
returns cached response. Endpoint never executes.CacheResponseCaptureMiddleware buffers the response body
and stores it in Redis after the endpoint returns.docs/guide/architecture.md § Why not a full ASGI middleware.Cached entries are Redis string keys with eviction-group prefixes.
Namespace deletion uses SCAN + DEL. Hash-based storage (faster
eviction-group deletion via single DEL) is a future opt-in gated on
Redis ≥ 8.0. See docs/guide/architecture.md § Storage model.
Three independent OTel layers (each opt-in):
opentelemetry-instrumentation-fastapi (external).FastAPIRedis(app)...otel() or
REDIS_OTEL_ENABLED=true. Install fastapi-redis-sdk[otel].REDIS_OTEL_REDIS_ENABLED=true or
opentelemetry-instrumentation-redis (not both).See docs/guide/architecture.md § Telemetry for span names and metrics.
tests/unit/): use fakeredis.aioredis, no real Redis.tests/integration/): real Redis, decorated with
@requires_redis (auto-skip if server unreachable).filterwarnings = ["error"] in pytest config — all warnings are errors.--cov-fail-under=80). The integration-only
session lowers this to 70 (_INTEGRATION_COV_FLOOR in noxfile.py) —
83 integration tests alone cover ~78% of src/.unit-tests runs
tests_unit across 3 OSes x 5 Pythons, integration-tests runs
tests_integration against Redis 8.8 and 7.4. See
docs/guide/compatibility.md § 4.asyncio_mode = "auto" — no need for @pytest.mark.asyncio.fake_async_redis — fakeredis instance, available in unit tests.real_redis / real_async_redis — real Redis clients for integration.All settings via env vars prefixed REDIS_ or .env file.
Key vars: REDIS_URL, REDIS_HOST, REDIS_PORT, REDIS_PASSWORD,
REDIS_SSL, REDIS_CLUSTER, REDIS_PREFIX, REDIS_DEFAULT_TTL.
Sentinel mode: REDIS_SENTINEL=true, REDIS_SENTINEL_NODES (comma-separated
host:port), REDIS_SENTINEL_MASTER_NAME. The primary's pool is a
SentinelConnectionPool in _PoolState.async_pool; _PoolState.async_sentinel
holds the Sentinel clients, which the lifespan closes.
from __future__ import annotations in all source files.Union[] (not X | Y) for Python 3.10 compat in
deps.py and types.py (ruff rule UP007 ignored there).CI is defined in .github/workflows/ci.yml and delegates to nox sessions.
Do NOT add inline uv run ruff / uv run mypy commands to CI — use
uv run nox -s <session> so CI and local checks stay in sync.
uv_build as its build backend.
NEVER replace it with hatchling, setuptools, flit, or any other
build backend. All build config lives in pyproject.toml under
[build-system] and [tool.uv.build-backend].Depends() factories
(cache(), cache_evict(), cache_put()), NOT as decorators. NEVER
refactor DI based solutions to use a decorator-based approach (@cache). The DI
pattern is a deliberate design decision, see /guide/architecture.md
for more information.Default key: {prefix}:{eviction_group}:{path}:{sorted_query_params}.
Eviction group is wrapped in hash-tag braces {ns} for Redis Cluster
slot alignment. Query params are sorted alphabetically for determinism.
Headers are NOT part of the key — use a custom key_builder for
header-dependent responses (e.g. Accept).
Fixed-window expiry. Accessing a cached entry does NOT extend its TTL.
ttl=0 or ttl=None means no automatic expiration.
All Redis errors (RedisError, OSError) are caught and logged as
warnings. Cache reads return None/miss; writes are silently dropped.
Exceptions from endpoints are never cached — only successful responses.
Corrupted cache data is treated as a miss (auto-fallback).
anyio.from_thread.run takes a zero-arg callable returning an
awaitable, NOT a coroutine object. Wrap with lambda.SyncCacheBackendDep must be imported at module level when using
from __future__ import annotations, or FastAPI cannot resolve the type.uv add --dev in CI workflows — deps are managed by nox
sessions and pyproject.toml dependency groups.cache() reads get_settings() at dependency-creation time (when the
module loads), not per-request. Runtime setting changes won't be picked
up by already-registered routes.© redis, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in .github/skills/redis-fastapi of redis/fastapi-redis-sdk.
Open the folder on GitHubat commit ed7a579
FastAPI-Redis SDK Development 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.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| FastAPI-Redis SDK Development this skillredis/fastapi-redis-sdk | 404 | — | ~2.5k | Automated safety check: Notes | MIT | |
| Python Redis Module Skilljiushiwon/wg-skills | 110 | — | ~1.7k | Automated safety check: Notes | Apache-2.0 | |
| Spring Data Redisrrezartprebreza/spring-boot-skills | 296 | — | ~1.6k | Automated safety check: Pass | MIT | |
| Backend Analysis Skilljiushiwon/wg-skills | 110 | — | ~1k | Automated safety check: Pass | Apache-2.0 | |
| Funboost Faas Deployydf0509/funboost | 892 | — | ~956 | Automated safety check: Pass | None | |
| Python PatternsxenitV1/Antigravity-Workflows | 130 | 7 repos | ~2.2k | Automated safety check: Pass | MIT |
jiushiwon/wg-skills
Python Redis 模块快速集成技能。面向已拥有 FastAPI 项目骨架的开发者,提供 Redis 缓存、Session 存储、分布式锁、限流、消息队列等能力的快速集成。触发词:"Python Redis"、"FastAPI Redis"、"Redis 集成"、"redis cache"、"redis session"、"redis lock"、"redis 限流"、"redis…
rrezartprebreza/spring-boot-skills
A skill your agent uses when implementing caching, session storage, rate limiting, or any Redis integration.
jiushiwon/wg-skills
后端项目静态分析技能。不运行项目,直接扫描源码,为 Java(Spring Boot/Spring Cloud)、Go(Gin/Echo)、Python(FastAPI/Django/Flask)、Node.js(Express/NestJS) 项目产出 4 份报告:① 接口报告(全部 API 清单:方法/路径/入参/出参/鉴权)② 技术报告(语言/框架版本、中间件如…
ydf0509/funboost
当需要将 funboost 任务部署为 HTTP 微服务时使用。触发场景:通过 FastAPI/Flask/Django 暴露发布和查询接口、使用内置 FaaS router、无需手写 API 代码。关键词:FaaS, 微服务, FastAPI, Flask, Django, HTTP API, REST, fastapirouter, flaskblueprint, web deploy。
xenitV1/Antigravity-Workflows
Python development principles and decision-making. An agent skill from xenitV1/Antigravity-Workflows.
davila7/claude-code-templates
Plan and build production-ready FastAPI endpoints with async SQLAlchemy, Pydantic v2 models, dependency injection for auth, and pytest tests.
Categories
Guides development on the fastapi-redis-sdk library itself - its connection lifecycle, dependency-injected caching, and async/sync bridging. This skill is scoped to writing code, tests or configuration for the fastapi-redis-sdk library, the official Redis integration for FastAPI, not general Redis or FastAPI questions. It lays out the project's layout, its uv and nox tooling for installing dependencies and running checks locally, and a hard architecture rule: Redis pools must be initialized through the app's lifespan, since accessing the pool without one raises a runtime error.
FastAPI-Redis SDK Development fits situations like: adding a feature or fixing a bug in fastapi-redis-sdk itself; writing tests for the library's caching or lifespan behavior; understanding the library's async/sync caching architecture before changing it.
Run `npx skills add redis/fastapi-redis-sdk --skill fastapi-redis-sdk -a claude-code`. Or copy the skill folder (.github/skills/redis-fastapi in redis/fastapi-redis-sdk) into .claude/skills/fastapi-redis-sdk in your project. Claude Code loads it when a task matches its description.
Run `npx skills add redis/fastapi-redis-sdk --skill fastapi-redis-sdk -a codex`. Or copy the skill folder (.github/skills/redis-fastapi in redis/fastapi-redis-sdk) into .agents/skills/fastapi-redis-sdk in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add redis/fastapi-redis-sdk --skill fastapi-redis-sdk -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/fastapi-redis-sdk, .gemini/skills/fastapi-redis-sdk, .github/skills/fastapi-redis-sdk and .opencode/skills/fastapi-redis-sdk in your project.
Going by SKILL.md and its folder, FastAPI-Redis SDK Development needs the command-line tools its instructions call (uv) and credentials named REDIS_PASSWORD. Our summary lists: uv; nox.
SKILL.md contains no URLs. Its commands use uv, which can reach the network depending on how they are called. This is read from the text; nothing was executed.
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.
FastAPI-Redis SDK Development is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.5k tokens (SKILL.md is roughly 9.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with FastAPI-Redis SDK Development: Python Redis Module Skill (jiushiwon/wg-skills, 110 stars), Spring Data Redis (rrezartprebreza/spring-boot-skills, 296 stars), Backend Analysis Skill (jiushiwon/wg-skills, 110 stars) and Funboost Faas Deploy (ydf0509/funboost, 892 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
redis (a GitHub organization, an official publisher) maintains it in redis/fastapi-redis-sdk, which has 404 GitHub stars. The repository was last updated on October 1, 2026.
Source: redis/fastapi-redis-sdk on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.