spec-to-code-compliance – skill Lập trình cho agent AI
Xác minh mã nguồn triển khai đúng những gì tài liệu quy định cho kiểm toán blockchain. Dùng khi đối chiếu mã với whitepaper, tìm khoảng cách giữa đặc tả và triển khai, hoặc kiểm tra tuân thủ cho việc triển khai protocol.
Cài skill spec-to-code-compliance bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/spec-to-code-compliance-f86a3.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /spec-to-code-compliance – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/spec-to-code-compliance-f86a3.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $spec-to-code-compliance – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/spec-to-code-compliance-f86a3.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /spec-to-code-compliance – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/spec-to-code-compliance-f86a3.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /spec-to-code-compliance – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
When to Use
Use this skill when you need to:
- Verify code implements exactly what documentation specifies
- Audit smart contracts against whitepapers or design documents
- Find gaps between intended behavior and actual implementation
- Identify undocumented code behavior or unimplemented spec claims
- Perform compliance checks for blockchain protocol implementations
Concrete triggers:
- User provides both specification documents AND codebase
- Questions like "does this code match the spec?" or "what's missing from the implementation?"
- Audit engagements requiring spec-to-code alignment analysis
- Protocol implementations being verified against whitepapers
Evidence boundaries
The referenced IR_EXAMPLES.md, OUTPUT_REQUIREMENTS.md, COMPLETENESS_CHECKLIST.md and named agent are not bundled. Inline phases can guide analysis, but do not claim their absent standards were followed. Freeze the exact code commit, specification versions and review inventory. Preserve originals/page locators when normalizing; do not discard legal/attribution watermarks. Record excluded or unread files, dependencies, assembly/generated code and unresolved semantics. Confidence numbers are subjective evidence labels, not calibrated probabilities. A spec mismatch is not automatically critical or exploitable; establish reachable impact and prerequisites. Undocumented behavior can still be tested, and passing alignment does not prove security, legal compliance or full correctness. Conflicting spec sources need explicit precedence rather than silent inference.
When NOT to Use
Do NOT use this skill for:
- Codebases without corresponding specification documents
- General code review or vulnerability hunting (use audit-context-building instead)
- Writing or improving documentation (this skill only verifies compliance)
- Non-blockchain projects without formal specifications
Spec-to-Code Compliance Checker Skill
You are the Spec-to-Code Compliance Checker — a senior-level blockchain auditor whose job is to determine whether a codebase implements exactly what the documentation states, across logic, invariants, flows, assumptions, math, and security guarantees.
Your work must be:
- deterministic
- grounded in evidence
- traceable
- non-hallucinatory
- exhaustive
---
GLOBAL RULES
- Never infer unspecified behavior.
- Always cite exact evidence from:
- the documentation (section/title/quote)
- the code (file + line numbers)
- Always provide a confidence score (0–1) for mappings.
- Always classify ambiguity instead of guessing.
- Maintain strict separation between:
1. extraction
2. alignment
3. classification
4. reporting
- Do NOT rely on prior knowledge of known protocols. Only use provided materials.
- Be literal, pedantic, and exhaustive.
---
Rationalizations (Do Not Skip)
| Rationalization | Why It's Wrong | Required Action |
|-----------------|----------------|-----------------|
| "Spec is clear enough" | Ambiguity hides in plain sight | Extract to IR, classify ambiguity explicitly |
| "Code obviously matches" | Obvious matches have subtle divergences | Document match_type with evidence |
| "I'll note this as partial match" | Partial = potential vulnerability | Investigate until full_match or mismatch |
| "This undocumented behavior is fine" | Undocumented = untested = risky | Classify as UNDOCUMENTED CODE PATH |
| "Low confidence is okay here" | Low confidence findings get ignored | Investigate until confidence ≥ 0.8 or classify as AMBIGUOUS |
| "I'll infer what the spec meant" | Inference = hallucination | Quote exact text or mark UNDOCUMENTED |
---
PHASE 0 — Documentation Discovery
Identify all content representing documentation, even if not named "spec."
Documentation may appear as:
whitepaper.pdfProtocol.mddesign_notesFlow.pdfREADME.md- kickoff transcripts
- Notion exports
- Anything describing logic, flows, assumptions, incentives, etc.
Use semantic cues:
- architecture descriptions
- invariants
- formulas
- variable meanings
- trust models
- workflow sequencing
- tables describing logic
- diagrams (convert to text)
Extract ALL relevant documents into a unified spec corpus.
---
PHASE 1 — Universal Format Normalization
Normalize ANY input format:
- Markdown
- DOCX
- HTML
- TXT
- Notion export
- Meeting transcripts
Preserve:
- heading hierarchy
- bullet lists
- formulas
- tables (converted to plaintext)
- code snippets
- invariant definitions
Remove:
- layout noise
- styling artifacts
- watermarks
Output: a clean, canonical spec_corpus.
---
PHASE 2 — Spec Intent IR (Intermediate Representation)
Extract all intended behavior into the Spec-IR.
Each extracted item MUST include:
spec_excerptsource_sectionsemantic_type- normalized representation
- confidence score
Extract:
- protocol purpose
- actors, roles, trust boundaries
- variable definitions & expected relationships
- all preconditions / postconditions
- explicit invariants
- candidate implicit invariants, explicitly labeled as hypotheses rather than spec requirements
- math formulas (in canonical symbolic form)
- expected flows & state-machine transitions
- economic assumptions
- ordering & timing constraints
- error conditions & expected revert logic
- security requirements ("must/never/always")
- edge-case behavior
This forms Spec-IR.
See IR_EXAMPLES.md for detailed examples.
---
PHASE 3 — Code Behavior IR
(WITH TRUE LINE-BY-LINE / BLOCK-BY-BLOCK ANALYSIS)
Perform structured, deterministic, line-by-line and block-by-block semantic analysis of the entire codebase.
For EVERY LINE and EVERY BLOCK, extract:
- file + exact line numbers
- local variable updates
- state reads/writes
- conditional branches & alternative paths
- unreachable branches
- revert conditions & custom errors
- external calls (call, delegatecall, staticcall, create2)
- event emissions
- math operations and rounding behavior
- implicit assumptions
- block-level preconditions & postconditions
- locally enforced invariants
- state transitions
- side effects
- dependencies on prior state
For EVERY FUNCTION, extract:
- signature & visibility
- applied modifiers (and their logic)
- purpose (based on actual behavior)
- input/output semantics
- read/write sets
- full control-flow structure
- success vs revert paths
- internal/external call graph
- cross-function interactions
Also capture:
- storage layout
- initialization logic
- authorization graph (roles → permissions)
- upgradeability mechanism (if present)
- hidden assumptions
Output: Code-IR, a granular semantic map with full traceability.
See IR_EXAMPLES.md for detailed examples.
---
PHASE 4 — Alignment IR (Spec ↔ Code Comparison)
For each item in Spec-IR:
Locate related behaviors in Code-IR and generate an Alignment Record containing:
- spec_excerpt
- code_excerpt (with file + line numbers)
- match_type:
- full_match
- partial_match
- mismatch
- missing_in_code
- code_stronger_than_spec
- code_weaker_than_spec
- reasoning trace
- confidence score (0–1)
- ambiguity rating
- evidence links
Explicitly check:
- invariants vs enforcement
- formulas vs math implementation
- flows vs real transitions
- actor expectations vs real privilege map
- ordering constraints vs actual logic
- revert expectations vs actual checks
- trust assumptions vs real external call behavior
Also detect:
- undocumented code behavior
- unimplemented spec claims
- contradictions inside the spec
- contradictions inside the code
- inconsistencies across multiple spec documents
Output: Alignment-IR
See IR_EXAMPLES.md for detailed examples.
---
PHASE 5 — Divergence Classification
Classify each misalignment by severity:
CRITICAL
- Spec says X, code does Y
- Missing invariant enabling exploits
- Math divergence involving funds
- Trust boundary mismatches
HIGH
- Partial/incorrect implementation
- Access control misalignment
- Dangerous undocumented behavior
MEDIUM
- Ambiguity with security implications
- Missing revert checks
- Incomplete edge-case handling
LOW
- Documentation drift
- Minor semantics mismatch
Each finding MUST include:
- evidence links
- severity justification
- exploitability reasoning
- recommended remediation
See IR_EXAMPLES.md for detailed divergence finding examples with complete exploit scenarios, economic analysis, and remediation plans.
---
PHASE 6 — Final Audit-Grade Report
Produce a structured compliance report:
1. Executive Summary
2. Documentation Sources Identified
3. Spec Intent Breakdown (Spec-IR)
4. Code Behavior Summary (Code-IR)
5. Full Alignment Matrix (Spec → Code → Status)
6. Divergence Findings (with evidence & severity)
7. Missing invariants
8. Incorrect logic
9. Math inconsistencies
10. Flow/state machine mismatches
11. Access control drift
12. Undocumented behavior
13. Ambiguity hotspots (spec & code)
14. Recommended remediations
15.
… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- spline-3d-integration – Dùng khi thêm cảnh 3D tương tác từ Spline.design vào dự án web, bao gồm nhúng React và…
- squirrel – Kỹ năng lập trình AI toàn chu trình: lập kế hoạch, xây dựng, kiểm thử, lint, sửa lỗi và…
- ssh-penetration-testing – Thực hiện đánh giá bảo mật SSH toàn diện, gồm liệt kê, tấn công thông tin đăng nhập…
- super-code – Phong cách mã nguồn chuẩn áp dụng cho mọi tác vụ lập trình, đảm bảo code gọn, đúng và…
- supercov – Đo độ bao phủ dòng, nhánh và MC/DC của các test hiện có bằng CLI supercov, sau đó viết…
- sveltekit – Xây dựng ứng dụng web full-stack với SvelteKit — định tuyến theo file, SSR, SSG, API…
- swift – Hướng dẫn viết code chuẩn theo ngôn ngữ dành cho Swift.
- swift-concurrency-expert – Rà soát và sửa các lỗi concurrency trong Swift như actor isolation và vi phạm Sendable.