提示词规则工程方法论

提示词规则工程方法论 is a skill for Claude Code, Codex from jianchen08/Agent-os-open. It costs 114 tokens per session (2,811 once invoked), scanned A, original, Apache-2.0.

A method for designing and changing instructions for AI systems, skills, and agent workflows. It treats those instructions like an interface specification with clear conditions, actions, outputs, tests, and versions.

In plain words
What is it for?
It is for writing or repairing system prompts, agent rules, tool-use instructions, and retrieval-augmented generation, or RAG, workflows.
Why use it?
It makes AI behavior easier to check, debug, update, and roll back when instructions are unclear or produce the wrong result.

Skill for Claude CodeCodex

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

Good fit It is for writing or repairing system prompts, agent rules, tool-use instructions, and retrieval-augmented generation, or RAG, workflows.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jianchen08/agent-os-open/prompt-rule-engineering
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 jianchen08/Agent-os-open --skill prompt-rule-engineering
Clone the repo
git clone --depth 1 https://github.com/jianchen08/Agent-os-open

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 提示词规则工程方法论

README.md
[![agentmods](https://agentmods.dev/badge/skills/jianchen08/agent-os-open/prompt-rule-engineering/github.svg)](https://agentmods.dev/skills/jianchen08/agent-os-open/prompt-rule-engineering)
Your own site
<a href="https://agentmods.dev/skills/jianchen08/agent-os-open/prompt-rule-engineering"><img src="https://agentmods.dev/badge/skills/jianchen08/agent-os-open/prompt-rule-engineering/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 提示词规则工程方法论

Your own site · 80×15
<a href="https://agentmods.dev/skills/jianchen08/agent-os-open/prompt-rule-engineering"><img src="https://agentmods.dev/badge/skills/jianchen08/agent-os-open/prompt-rule-engineering.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 114 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,811 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.
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.00114 $0.02811
Opus 5.5 $0.00046 $0.01124
Sonnet 5.5 $0.00023 $0.00562
Haiku 4.5 $0.00011 $0.00281

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

Security

Grade A, and why

提示词规则工程方法论 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 28d 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.

skills/prompt-rule-engineering/SKILL.md · 131 lines

How it starts

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

提示词 / Skill 规则工程方法论 v1.1

本技能是流程指引,不是逐条打勾清单:按场景判断使用,遇不适用情况保持裁量,不机械执行。

适用范围

LLM 系统提示词、Skill 规则、agent 工作流、RAG 指令、工具调用规范。 目标:省 token、准确、无歧义、可调试、可回归、可版本化。

一、总原则

  1. 提示词 = 接口规格:条件可判定、动作可执行、结果可验证、解释唯一。
  2. 改提示词 = 改代码:先复现失败,再定位最小部分,做最小补丁,最后回归测试。
  3. 一次只改一个因果维度:多版本并行(Candidate Beam)时,每个候选也各只改一处,否则无法归因哪个修改有效。
  4. 优先级固定,且在使用前声明:
    • 跨类冲突:P0 安全 > P1 任务正确性 > P2 输出格式 > P3 风格;高覆盖低。
    • 文档内冲突:规则 > 流程 > 示例。示例没有优先级位,永不推翻规则——示例与规则冲突时改示例或删示例,规则为准。
    • P# 只标注在存在真实冲突可能的规则上;无冲突可能的普通规则不强制编号。
  5. 术语全局唯一:关键名词定义一次全文一致;禁用「它/该/这个」跨句指代。
  6. 输出契约兜底:格式、字段、长度必须可验证;空/超长/失败/未知/冲突输入的行为必须定义。
  7. 版本化:每次变更留一行记录(格式见 §五),能回滚。

二、新写:契约结构(六层 + 两个可选层)

目标:一句话。
范围:做什么;非目标:不做什么(任务偏移先改这里)。
术语:A=…;B=…。
规则:当<可判定条件>,必须<可执行动作>;否则<默认>。
禁止:<禁止项> → <替代动作>(只写"不要"不给出路 = 不合格)。
输出:格式、字段、长度、异常输入处理(写得出验证方法才写)。
可选-流程:S# 输入→动作→输出→失败分支→下一步条件(多步骤任务时)。
可选-示例:仅边界例/反例,每类 ≤1;示例集跨输入类型/长度/复杂度多样化(防锚定)。

三、规则写法

  • 一条规则只做一件事;句式「当 X → 必须 Y;否则 Z」。
  • 用 必须 / 禁止 / 可;黑名单:尽量、适当、可能、一般来说、考虑、酌情、相关。
  • 量化只落在模型输出可控维度:字数、句数、条目数、轮次、字段名、必须包含的标记。时延、耗时等模型不可控量不得作为提示词量化指标。
  • 肯定句优先;禁止必须配替代动作。
  • 形态双轨:契约型用规则行,流程型用编号步骤或表格。合规判据是「可判定/可执行/可验证」,不是句式——表格行、流程步与规则行同等对待。

四、省 token

  • 删:客套、解释、重复、模型已知常识(通用教科书代码、概念科普不入提示词)。
  • 用:列表、短句、符号 → = ≠ ≤ ≥。
  • 合并同条件或同动作规则;用编号引用,不复述。
  • 变量占位:{input}、{lang}、{{path:…}}。
  • 冗余检查(瘦身测试):删去 30% 内容后行为契约不变 → 说明有冗余,删之。这是冗余检测,不是健壮性测试。

五、修复:症状 → 部分 → 改法

症状 先改 改法
任务偏移 目标/范围 缩非目标,重写目标一句
理解不一致 术语 加定义,全文统一替换
条件歧义 规则 量化条件,黑名单词清零
规则冲突 规则 加优先级声明,高覆盖低
步骤漏/乱 流程 编号步骤,加输入输出和前置条件
循环/不终止 流程 加最大轮次、终止条件
工具调用错 流程 明确调用条件、参数、失败分支
格式漂移 输出/规则 固定字段、长度、JSON schema
风格不对 示例/规则 加边界示例 + 禁止项
边界错 示例/规则 只加边界例或反例
引用断链/事实锚点过期 事实锚点 引用带路径;落档前验证目标存在(ls/读原文),过期锚点改为去路径化表述或更新为现状
多副本漂移 副本结构 单源 + 薄指针(见本仓 credit-delegation 先例),禁止多处存全文
回归口径不一 评估节 阈值与用例集规模集中定义一处

修复流程(单失败快路径)

  1. 收集失败样本:输入、输出、期望、环境。
  2. 最小复现:去掉无关上下文,仍失败才改。
  3. 归类到部分:目标 / 术语 / 规则 / 流程 / 示例 / 输出 / 上下文。
  4. 写测试:原失败 + 相似 + 反例 + 空/超长/异常。快速迭代默认 5–10 例,至少 1 例留出。
  5. 最小修改:只改归类部分。
  6. 回归:新旧版本同一评估集跑分对比,涨了才保留;否则回滚。
  7. 版本记录一行:v# 日期 | 改了什么 | 归因(失败签名) | 前分→后分 | 回滚点。

Read the full file on GitHub · 131 lines

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. 28d ago First seen · 131 lines · 114 tokens per session scan A 4bf606250914

Subscribe to this mod's changes

提示词规则工程方法论 is a skill published in the GitHub repository jianchen08/Agent-os-open (7 stars, last pushed 9d ago), licensed Apache-2.0. It adds 114 tokens to every session and 2,811 once invoked, about $0.0005 per session on Opus 5.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-09-19.

Related

Other skills, from other repositories

background-task

Add or modify work that runs outside the request/response cycle — emails, document ingestion, webhooks, cleanups, scheduled jobs. Use when something is slow or fire-and-forget, or when adding a periodic/cron task. This project's queue is {{ cookiecutter.backgroundtasks }}.

vstorm-co/full-stack-ai-agent-template · 62 tokens

agent-tool

Add a new tool/function the AI agent can call (e.g. look something up, hit an external API, perform an action). Use when extending the assistant's capabilities, wiring a new function into the agent, or when the model needs a new action. This project uses {{ cookiecutter.aiframework }}.

vstorm-co/full-stack-ai-agent-template · 66 tokens

frontend-feature

Build a new page, view, or data-driven feature in the Next.js frontend. Use when adding a route under the dashboard/marketing area, wiring UI to a backend endpoint, adding client state, or creating a localized page. Covers App Router, data fetching, Zustand stores, and i18n.

vstorm-co/full-stack-ai-agent-template · 64 tokens

rag-knowledge

Work with the RAG knowledge base — ingest documents, run semantic search, manage collections, or add a sync source/connector (Google Drive, S3). Use when populating or debugging the knowledge base, tuning retrieval, or adding a new document source. This project uses {{ cookiecutter.vectorstore }} + {{…

vstorm-co/full-stack-ai-agent-template · 76 tokens

alembic-migration

Create, review, and apply database schema changes with Alembic. Use whenever a SQLAlchemy model is added or changed, a column/index/constraint needs to change, or a data backfill is required — anything that alters the PostgreSQL schema.

vstorm-co/full-stack-ai-agent-template · 56 tokens

channel-bot

Work with messaging-channel bots (Telegram / Slack) — register a bot, route inbound messages through the AI agent, handle webhooks vs polling, or add a new channel adapter. Use when wiring chat into a messaging platform or debugging bot delivery.

vstorm-co/full-stack-ai-agent-template · 53 tokens