fastapi-ws-module-skill

fastapi-ws-module-skill is a skill for Claude Code, Codex from jiushiwon/wg-skills. It costs 133 tokens per session (4,050 once invoked), scanned A, original, Apache-2.0.

A FastAPI module for real-time one-to-one chat over WebSocket, a connection that stays open so messages can arrive immediately. It includes message storage, offline delivery, unread counts, conversations, and multiple-device login.

In plain words
What is it for?
Use it for text, image, and voice messages, friend-only conversations, offline messages, duplicate-safe retries, unread counts, and multi-device sessions.
Why use it?
It provides chat-related building blocks for an existing FastAPI project without requiring a separate messaging service.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for text, image, and voice messages, friend-only conversations, offline messages, duplicate-safe retries, unread counts, and multi-device sessions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jiushiwon/wg-skills/fastapi-ws-module-skill
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add jiushiwon/wg-skills --skill fastapi-ws-module-skill
Clone the repo
git clone --depth 1 https://github.com/jiushiwon/wg-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for fastapi-ws-module-skill

README.md
[![agentmods](https://agentmods.dev/badge/skills/jiushiwon/wg-skills/fastapi-ws-module-skill/github.svg)](https://agentmods.dev/skills/jiushiwon/wg-skills/fastapi-ws-module-skill)
Your own site
<a href="https://agentmods.dev/skills/jiushiwon/wg-skills/fastapi-ws-module-skill"><img src="https://agentmods.dev/badge/skills/jiushiwon/wg-skills/fastapi-ws-module-skill/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for fastapi-ws-module-skill

Your own site · 80×15
<a href="https://agentmods.dev/skills/jiushiwon/wg-skills/fastapi-ws-module-skill"><img src="https://agentmods.dev/badge/skills/jiushiwon/wg-skills/fastapi-ws-module-skill.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 133 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,050 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00133 $0.04050
Opus 5 $0.00067 $0.02025
Sonnet 5 $0.00027 $0.00810
Haiku 4.5 $0.00013 $0.00405

Measured 10d ago against content hash f768bf96b20e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

fastapi-ws-module-skill scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (references/skeleton.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

vibeCoding/backend/python/fastapi-module/fastapi-ws-module-skill/SKILL.md · 302 lines

How it starts

The opening of the file, as written. The whole thing — 302 lines — stays where its author put it; the contents beside it link to each section on GitHub.

FastAPI WebSocket Module Skill

为 FastAPI 项目叠加一套 WebSocket 即时通信能力,不是重新生成新项目。

定位

  • 目标:在已有 fastapi-init-skill 骨架上,添加可运行的 WebSocket 通信模块。
  • 不替代:不重复生成 fastapi-init-skill 已经提供的 JWT、统一响应、SQLAlchemy async 等基础设施。
  • 不做腾讯 IM:自建轻量方案,适合小中规模,不依赖第三方 IM 服务。
  • 输出:连接管理器、消息路由、消息存储、离线推送、会话管理、好友校验、接口契约。

骨架依赖(子模块)

本模块是 fastapi-init-skill 的子模块,必须在骨架基础上使用。

使用前必须满足以下条件:

  1. ✅ 已安装 fastapi-init-skill(项目骨架)
  2. ✅ 骨架包含:JWT、统一响应、SQLAlchemy async、分页、目录结构
  3. ✅ 遵循骨架的表前缀、字段命名、软删除规范

检测逻辑:

  1. 读取用户项目根目录,检查是否包含 fastapi-init-skill 的标志性文件(app/main.pyapp/config.pyapp/response.py
  2. 检查 app/dependencies.py 是否已有 get_current_user 依赖
  3. 如未检测到骨架,提示:"本模块需要先安装 fastapi-init-skill 骨架"
  4. 如用户拒绝安装骨架,则终止并提示无法使用

用户问题(最多 3 个)

1. 现有项目的包名是什么?(默认从 fastapi-init-skill 推断,如 app)
2. 表前缀是什么?(默认 wg)
3. 是否需要群聊?(默认不需要,先做单聊)

核心能力清单

# 能力 说明
1 WebSocket 长连接 WS /api/ws?token=<jwt>,query 参数鉴权,多端登录(PC/手机/Web 同时在线)
2 单聊消息 文本/图片/语音实时投递,在线直推,离线入库
3 好友校验 仅允许已通过好友互发消息,避免陌生人骚扰
4 消息幂等 客户端传 client_msg_id,网络抖动重发不重复入库
5 离线消息 用户上线时自动推送未送达消息(最多 100 条)
6 未读数 单聊未读计数,支持清零 + 实时通知对方
7 会话列表 最近会话排序,最后一条消息预览
8 聊天记录 基于 cursor 翻页的历史消息查询
9 消息状态 未读 → 已送达 → 已读 三态流转
10 接口契约 生成 api-contract-ws.md,与 frontend-request-skill 对齐

生成流程

  1. 确认已存在 FastAPI 骨架(含 JWT、统一响应、分页)。
  2. 询问用户包名、表前缀(默认 wg)、是否需要群聊。
  3. references/skeleton.py 生成 ws/ 下全部源码:
    • 将所有 {prefix} 占位符替换为用户指定的表前缀(如 wg_
    • app.ws 替换为用户的包名(如 app.ws
  4. 生成 api-contract-ws.mddocs/ws-module-guide.md
  5. app/main.py 注册 WebSocket 路由。
  6. 提示用户:重启服务后可通过 WebSocket 客户端测试连接。

模块结构

{{PROJECT_NAME}}/
├── app/
│   ├── ws/
│   │   ├── __init__.py
│   │   ├── manager.py          # WebSocket 连接管理器(多端登录)
│   │   ├── heartbeat.py        # 心跳保活(任何消息都算心跳)
│   │   ├── handler.py          # 消息路由与处理(好友/幂等/校验/落库/推送)
│   │   ├── friend.py           # 好友关系校验
│   │   ├── validators.py       # 消息内容校验 + 预览生成
│   │   ├── offline.py          # 离线消息推送
│   │   ├── models/
│   │   │   ├── __init__.py
│   │   │   ├── message.py      # {prefix}_chat_message 消息表
│   │   │   ├── conversation.py # {prefix}_chat_conversation 会话表
│   │   │   └── friend.py       # {prefix}_user_friend 好友表
│   │   ├── schemas/
│   │   │   ├── __init__.py
│   │   │   ├── message.py      # 消息入参/出参(含 image_url/voice_url 等)
│   │   │   └── conversation.py # 会话入参/出参 + MarkReadRequest
│   │   ├── services/
│   │   │   ├── __init__.py
│   │   │   ├── message_service.py       # 消息存储与查询
│   │   │   └── conversation_service.py  # 会话管理
│   │   └── routers/
│   │       ├── __init__.py
│   │       ├── ws.py           # WebSocket 端点 /api/ws
│   │       ├── chat.py         # REST 接口(历史/会话/未读/已读/发消息)
│   │       └── friend.py       # 好友 REST 接口(可选,没装 auth-module-skill 时兜底)
├── alembic/
│   └── versions/
│       └── ws_module.py        # 迁移文件
├── api-contract-ws.md          # 接口契约
└── docs/
    └── ws-module-guide.md      # 接入指南

Read the full file on GitHub · 302 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 302 lines · 133 tokens per session scan A f768bf96b20e

Subscribe to this mod's changes

fastapi-ws-module-skill is a skill published in the GitHub repository jiushiwon/wg-skills (98 stars, last pushed yesterday), licensed Apache-2.0. It adds 133 tokens to every session and 4,050 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

mem0-oss-to-platform

Plan and then execute a migration of a project from the mem0 open-source / self-hosted SDK (the local Memory class) to the mem0 Platform / hosted / managed SDK (the MemoryClient class). Use this whenever a developer wants to move, switch, or migrate their mem0 usage off OSS/self-hosted to the hosted API — e.g.…

mem0ai/mem0 · 273 tokens

agui-dotnet-protobuf

Use the protobuf wire transport (instead of the default Server-Sent Events) for an AG-UI connection with the AG-UI .NET SDK — a compact binary event stream negotiated via the Accept header. USE FOR: making an AGUIChatClient prefer protobuf by wiring an AGUIEventStreamHandler with ProtobufEventStreamFormatter (then…

ag-ui-protocol/ag-ui · 162 tokens

azure-mgmt-botservice-dotnet

Azure Resource Manager SDK for Bot Service in .NET. Management plane operations for creating and managing Azure Bot resources, channels (Teams, DirectLine, Slack), and connection settings. Triggers: "Bot Service", "BotResource", "Azure Bot", "DirectLine channel", "Teams channel", "bot management .NET", "create bot".

microsoft/skills · 78 tokens

fastapi-router-py

Create FastAPI routers with CRUD operations, authentication dependencies, and proper response models. Use when building REST API endpoints, creating new routes, implementing CRUD operations, or adding authenticated endpoints in FastAPI applications.

microsoft/skills · 46 tokens

migrate-segw-to-rap

Reverse-engineer a SEGW-built OData V2 service (MPC/DPC/MPCEXT/DPCEXT) into a modern RAP V4 service — tables, CDS views (interface + projection), behavior definitions, draft entities, service definition + binding. Use when asked to "migrate this SEGW service to RAP", "convert OData V2 to V4 RAP", "modernize this…

arc-mcp/arc-1 · 106 tokens

telnyx-messaging-hosted-curl

Set up hosted SMS numbers, toll-free verification, and RCS messaging. Use when migrating numbers or enabling rich messaging features. This skill provides REST API (curl) examples.

team-telnyx/ai · 45 tokens