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.
git clone --depth 1 https://github.com/zhangdszq/teamclawWrote 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.
[](https://agentmods.dev/rules/zhangdszq/teamclaw/bot-runner-reuse)<a href="https://agentmods.dev/rules/zhangdszq/teamclaw/bot-runner-reuse"><img src="https://agentmods.dev/badge/rules/zhangdszq/teamclaw/bot-runner-reuse/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.
<a href="https://agentmods.dev/rules/zhangdszq/teamclaw/bot-runner-reuse"><img src="https://agentmods.dev/badge/rules/zhangdszq/teamclaw/bot-runner-reuse.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.00876 |
| Opus 5.5 | $0.00000 | $0.00350 |
| Sonnet 5.5 | $0.00000 | $0.00175 |
| Haiku 4.5 | $0.00000 | $0.00088 |
Grade A, and why
bot-runner-reuse 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 1mo ago.
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.
How it starts
The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Bot / Runner 复用架构规范
核心原则
业务逻辑(AI 调用、persona 构建、历史上下文、消息持久化)必须提取到共享层,各 bot 只负责平台 I/O。
共享层位置:src/electron/libs/bot-base.ts
❌ 禁止:在 bot 文件内重复实现
以下函数在 telegram/dingtalk/feishu 三个 bot 里各有一份,不要再复制:
// ❌ BAD — 每个 bot 各自有一份 buildQueryEnv
function buildQueryEnv(): Record<string, string | undefined> {
const settings = loadUserSettings();
const apiKey = settings.anthropicAuthToken || process.env.ANTHROPIC_API_KEY || "";
// ... 三处完全相同
}
// ❌ BAD — runClaudeQuery 写死在 telegram-bot.ts 里
async function runClaudeQuery(session, prompt, opts) {
const env = buildQueryEnv(); // 内嵌逻辑
// ... 50 行重复逻辑
}
✅ 正确:从 bot-base.ts 导入共享函数
// bot-base.ts — 共享层
export function buildQueryEnv(): Record<string, string | undefined>
export function buildStructuredPersona(opts: BaseBotOptions, extras?: string[]): string
export function buildHistoryContext(history: ConvMessage[], assistantId?: string): string
export async function runClaudeQueryBase(
opts: BaseBotOptions,
userText: string,
sendReply: (text: string) => Promise<void>, // 平台回调,由各 bot 传入
sendFile?: (path: string) => Promise<void>,
): Promise<void>
export async function persistReply(assistantId: string, role: string, content: string): Promise<void>
// telegram-bot.ts — 只负责平台 I/O
import { buildQueryEnv, buildStructuredPersona, runClaudeQueryBase } from "./bot-base.js";
bot.on("message", async (ctx) => {
await runClaudeQueryBase(opts, ctx.message.text, (reply) => ctx.reply(reply));
// ↑ Telegram 专属的发送函数
});
✅ Runner 复用规范
多个 assistant 共享同一 runner,通过 assistantId 隔离会话,不要为每个 assistant 新建独立 runner 实例:
// ❌ BAD — 为每个 bot 硬编码 session 前缀
const sessionId = `tg-${chatId}`; // telegram-bot.ts
const sessionId = `dt-${senderStaffId}`; // dingtalk-bot.ts
// ✅ GOOD — 统一格式,由 bot-base 生成
export function buildSessionId(platform: BotPlatformType, assistantId: string, userId: string) {
return `${platform}:${assistantId}:${userId}`;
}
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.
- 1mo ago First seen · 100 lines · 0 tokens per session scan A c3abcbf0e77a
bot-runner-reuse is a cursor rule published in the GitHub repository zhangdszq/teamclaw (113 stars, last pushed 7mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 876 tokens. 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.
Other cursor rules, from other repositories
api-property-optionality-hygiene
Fix ApiProperty/ApiPropertyOptional optionality mismatches in DTO files; use for scheduled batch fixes or DTO edits.
python
Python best practices and patterns for modern software development with Flask and SQLite.
cursor
You are working on the checkout service. Preserve transaction integrity and auditability.
django
Definitive guidelines for writing maintainable, performant, and secure Django applications, emphasizing modern best practices, clear code organization, and efficient patterns.
server-state
USE WHEN: Fetching and caching server data with TanStack Query 5: queryOptions, hooks, mutations, invalidation.
selectools-providers
Rules for working with LLM provider adapters in selectools.