intended-vs-implemented
phuryn/pm-skills
能在程式碼庫中找出文件記載的意圖與實際實作之間的落差,並偵測到一般掃描工具因缺乏意圖模型而忽略的錯誤。
...展開全部「預期」與「實際」:審計差距
目的
程式碼檢查工具是在真空狀態下掃描程式碼的。它能告訴你程式碼在內部是否一致;但無法告訴你程式碼是否確實實現了你的原意,因為它沒有你意圖的模型。 最具價值的安全性與正確性缺陷,正存在於這個落差之中——例如文件中記載卻從未執行的權限、任何人都能呼叫的「僅限 cron 執行」端點,或是標記為「僅限 public」卻洩漏私有資料的欄位。
這項技能正是用來找出該差距的方法。它也是區別於其他工具的關鍵:唯有當意圖已事先以文字形式記錄下來時(參見「發佈產物」技能),此技能才有效,而這正是通用工具無法複製它的原因。
背景
當已存在書面記載的意圖時,請使用此技能—— permissions.md, architecture.md, variables.md等。若相關文件缺失或過時,這種缺失本身即是第一個發現:你無法審計從未記錄過的意圖。建議先進行文件記錄,再進行審計。
方法
確立意圖。將
/documentation/*.md該文件集作為「應然狀態」的權威來源:誰可存取什麼、哪些邊界是可信的、哪些資料是公開的。將文件視為待驗證的聲明,而非證明。蒐集實作證據。閱讀執行(或未能執行)每項聲明的程式碼。證據是指明檔案與行號——實際的授權檢查、實際的查詢篩選器、實際的資料淨化程式。「這可能在上游已處理」並非證據;程式執行路徑才是。
逐個邊界地將聲明與程式碼進行比對。針對每項文件記載的規則,請自問:執行點是否確實於伺服器上、在每個路徑中都落實了該規則?對「僅限內部」、「僅限管理員」或「已在其他處驗證」等註解應持懷疑態度——務必透過程式碼加以驗證。
根據其重要性對每項不一致進行分類。當跨越該不一致會讓真實攻擊者取得不該取得的資料、金錢、基礎設施或其他租戶時,該不一致即屬重要;若唯一受影響者僅是攻擊者自身及其自有資料,則不重要。忽略表面上的偏差;保留跨越邊界的偏差。
避免含糊其辭的發現。每項發現都應明確標示:文件記載的意圖(引用文件)、實際的實作狀況(引用程式碼)、攻擊者與受害者,以及具體的修正方案。若無法同時引用差距的兩方面,那只是需要調查的問題,而非應報告的發現。
什麼才算數
- 意圖:文件中記載的規則、邊界、範圍,或公開/私有分類。
- 實作證據:程式碼中引用的強制執行點(或其可證明的不存在)。
- 具有實質影響的不一致:文件所述與程式碼實際行為不符,且此差異跨越了信任、成本、資料或租戶邊界。
備註
- 「已記錄但未執行」本身即構成一項發現——應根據跨越此差距所暴露的風險來進行分級。
- 「未記錄但已執行」通常無妨,但應標記:文件現已過時,這將削弱下次稽核的有效性。
- 此方法可作為安全與效能稽核的參考依據;它並未取代這些稽核的底層分析——而是補充了它們所缺乏的「意圖」維度。
- 切勿捏造意圖來製造差距。若文件未提及,請如實指出文件未提及。
---
name: intended-vs-implemented
description: Finds gaps between documented intent and actual implementation in codebases, catching bugs that generic scanners miss because they lack a model of intent.
---
# Intended vs. Implemented: Auditing the Gap
## Purpose
A linter scans code in a vacuum. It can tell you the code is *internally* consistent; it cannot tell you the code does what you *meant*, because it has no model of your intent. The highest-value security and correctness bugs live in that gap — a permission documented but never enforced, a "cron-only" endpoint anyone can call, a field marked public-only that leaks private data.
This skill is the method for finding that gap. It is the differentiator: it only works when intent has been written down first (see the **shipping-artifacts** skill), and that's exactly why commodity tools can't replicate it.
## Context
Use this when documented intent exists — `permissions.md`, `architecture.md`, `variables.md`, etc. If those docs are absent or stale, that absence is itself the first finding: you cannot audit intent you never recorded. Recommend documenting first, then auditing.
## Method
1. **Establish intent.** Read the `/documentation/*.md` set as the source of truth for what *should* be true: who may access what, which boundaries are trusted, which data is public. Treat the docs as claims to verify, not as proof.
2. **Gather implementation evidence.** Read the code that enforces (or fails to enforce) each claim. Evidence is a cited file and line — the actual authorization check, the actual query filter, the actual sanitizer. "It's probably handled upstream" is not evidence; the code path is.
3. **Compare claim to code, one boundary at a time.** For each documented rule, ask: does an enforcement point actually implement it, on the server, on every path? Distrust comments like "internal only," "admin only," or "validated elsewhere" — verify them in code.
4. **Classify each mismatch by whether it matters.** A mismatch matters when crossing it lets a real actor reach data, money, infrastructure, or another tenant they shouldn't. It does not matter when the only person affected is the actor themselves on their own data. Drop cosmetic drift; keep boundary-crossing drift.
5. **Avoid hand-wavy findings.** Every finding names: the **documented intent** (quote the doc), the **implemented reality** (cite the code), the **attacker and victim**, and the **concrete fix**. If you cannot cite both sides of the gap, it is a question to investigate, not a finding to report.
## What counts
- **Intent:** a documented rule, boundary, scope, or public/private classification.
- **Implementation evidence:** a cited enforcement point (or its provable absence) in the code.
- **A mismatch that matters:** doc says one thing, code does another, and the difference crosses a trust, cost, data, or tenant boundary.
## Notes
- Documented-but-unenforced is a finding on its own — rank it by what crossing the gap exposes.
- Undocumented-but-enforced is usually fine, but flag it: the docs are now stale, which weakens the next audit.
- This method feeds the security and performance audits; it does not replace their sink-level analysis — it adds the intent axis they lack.
- Never fabricate intent to manufacture a gap. If the docs are silent, say the docs are silent.
所有檔案
1 個檔案安裝 intended-vs-implemented
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/phuryn/pm-skills/tree/main/pm-ai-shipping/skills/intended-vs-implemented # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
