prompt-contract-maintenance
Use when editing multi-pass LLM prompt contracts.
- License 许可
- MIT
- 最近更新
- 2026-10-20
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- prompt-contract-maintenance
- author
- Hermes Agent
- license
- MIT
- version
- 1.0.0
- metadata
- { "hermes": { "tags": [ "prompts", "llm-pipelines", "structured-output", "schema", "prompt-audit" ], "related_skills": [ "test-driven-development", "systematic-debugging", "prompt-engineer" ] } }
- platforms
- [ "linux", "macos", "windows" ]
- description
- Use when editing multi-pass LLM prompt contracts.
02 资源文件 2
- 参考文档references/foreign-prompt-architecture.md5.3 KB
- 参考文档references/prompt-audit-checklist.md3.9 KB
03 SKILL.md 正文
Prompt Contract Maintenance
In a multi-pass LLM pipeline a prompt is an API: the system prompt states a shape, the parser enforces a shape, and the store persists it. Changing one without the others ships a model reply nothing accepts, or a rule the guard makes unreachable.
When to use
- Adding or reworking sections of a layer / reviewer / adviser prompt.
- Unifying vocabulary across passes (entity or marker types, advice targets, severity levels).
- Changing an output contract: allowing empty values, renaming keys, new count or length caps.
- Auditing why a prompt's stated rule never takes effect in stored artifacts.
- Explaining another project's prompt architecture (usually: file:line map + structure read-out,
verbatim text only on request). For a shipped agent whose prompts travel inside a binary or an
installed package, follow
references/foreign-prompt-architecture.md— version-pinned extraction, provenance hash, composition map before any text dump.
Workflow
-
Inventory before editing. Grep the prompt constants, then for each one find: the call that passes it as the system message, the user-message builder that supplies its input blocks, the parse/normalize function that consumes the reply, and the store writer. Write the prompt → parser → store triple per pass. A section cannot be judged without its consumer.
-
Section skeleton, in this order:
ROLE— what the pass owns, plus an explicit "what you are not" line (not the assistant, not the implementer, not a second writer).INPUTS+TRUST ORDER— the blocks that actually arrive, ranked.WORKFLOW— numbered steps naming those blocks in the order the builder emits them.- JSON shape,
OUTPUT CONTRACT, per-topic rules, thenDEFINITIONSlast. - Definitions go last so the body reads top-down while the reference block stays self-contained even though its text is generated once and shared.
-
Single-source every shared vocabulary. Put the table in the lightest shared module (prompt formatting module, not the store), expose
glossary()/section()string builders, and compose every prompt that mentions the vocabulary from them. Four hand-written copies of the same five type definitions drift within one release. Attach the generated sections to the shared contract constant itself when several prompts compose it (cold start, audit, reconcile, retry): a section appended only in the primary system-prompt composer silently disappears from every variant. -
Compose, never f-string a prompt that embeds JSON. Braces in the example object collide with replacement fields, and doubling every brace is silent-corruption risk. Attach generated sections by concatenation:
"""static body""" + "\n\n" + marker_section(). The same rule kills placeholder-then-replace()schemes. -
Audit prompt ↔ parser symmetry before declaring the edit done — see
references/prompt-audit-checklist.mdfor the check matrix and commands. The recurring misses: a count or character limit stated in the prompt but enforced wider (or narrower) by the parser; a "you are given X" claim the builder does not supply; a section order claim that does not match the built message. -
Move behaviour end-to-end when the rule is semantic. A rule like "an empty listed field clears the card" needs four edits in one change: prompt text, parser/guard, store write, and README. Keep the neighbouring negative path (placeholder or unlisted empty = not a correction) and test both.
-
Verify with the repo's own suite. Prove pre-existing failures with a clean tree instead of guessing (
git worktree add <dir> HEAD), and treat full-suite-only failures as flakes after one isolated rerun. Report the failing test name, its real cause, and whether it predates the change.
Pitfalls
- Section text contradicts the builder. A ROLE line claiming "the window is the only evidence" while the builder also supplies a first-message anchor and operator files teaches the model to ignore evidence you feed it. Read the builder before writing any inputs/trust claim.
- The guard makes the new rule dead on arrival. A review that rejects empty cards can never
clear one; a parser that drops
[unknown]items cannot accept a placeholder rule. Change guard and prompt together and keep both branches tested. - Placeholders leak into artifacts.
[unknown]-style fillers are only safe when write-back filters them; check the store writer before adding such a rule, and never let a placeholder reach a persisted card. - Test builders swallow empty values. Helpers written as
value or defaultcannot express[]; switch tovalue if value is not None else defaultbefore writing an empty-state test. - Normalization erases empty vs missing. A
_json_items/_string_listhelper returns[]for an omitted key, a malformed value and an explicit empty list, so an "[]clears this field" rule cannot be read after normalization. Decide clears from the raw reply object (payload.get(field) == []), require the field in the change list, and keep a non-list value from counting as a clear. - Snapshot vs live row. Revision/audit tables usually store the pre-change snapshot while the live row carries the change. Assert the old value on the snapshot and the new value on the live row; asserting both on the same row fails for the wrong reason.
- Prompt growth is real cost. A generated glossary section costs roughly 400-900 characters per prompt per run; prefer one shared table over per-prompt prose and state the delta when reporting.
- Duplicated vocabulary already in flight. Before adding a definition, search the pipeline for an existing one (store constants, tool descriptions, provider system block). Extend that source instead of creating a second.
Reporting
Lead with the file:line map of what changed (prompt constant, parser, store, tests) and the structural findings; keep verbatim prompt text out of the summary unless requested. When the request is "show me the system prompt", the reply carries the full text and the composition map; a file path is a supplement, never the answer. Separate "fixed" from "found but needs a decision" — contract asymmetries are often intentional.
04 同仓库更多 Skills
web-retrieval-resilience
Web tools fail or search rules break: repair or fall back.
blocked-page-recovery
Use when a fetch fails: 403/429, paywall, WAF, bot wall.
verification-loop
Run a six-phase verification of a Claude Code session's work — build, type check, lint, tests with coverage, security grep, and diff review — then produce a PASS/FAIL verification report. Use when verifying work after completing a feature or refactor, before creating a PR, or when quality gates must pass.
unreal-world-builder
开放世界与环境专家——精通 UE5 World Partition、Landscape、程序化植被、HLOD 和大规模关卡流式加载,打造无缝开放世界体验
unreal-technical-artist
Unreal Engine 视觉管线专家——精通材质编辑器、Niagara 特效、程序化内容生成和 UE5 项目的美术到引擎管线
unreal-systems-engineer
性能与混合架构专家——精通 C++/Blueprint 边界、Nanite 几何体、Lumen GI 和 Gameplay Ability System,面向 AAA 级 Unreal Engine 项目