Agent skill · AI & Agents

cc-prompt-craft

System Prompt 工程 — 基於 Claude Code 914 行系統提示詞的逆向分析。Use when: 撰寫 system prompt、設計 prompt 動態組裝、最佳化 prompt cache 效率、撰寫安全指令。

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill cc-prompt-craft --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 3 KB
Bundled scripts: none
Version: 202603
Path: skills/ai-llm/cc-prompt-craft/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# System Prompt 工程 基於 Claude Code v2.1.88 的 914 行系統提示詞逆向分析。 ## 1. Prompt 結構順序 Claude Code 的 system prompt 按以下順序組裝: ``` 1. 身份宣告(你是誰) 2. 工具使用指引(怎麼用工具) 3. 行為規範(做事風格) 4. 安全指令(不能做什麼) 5. 環境資訊(動態注入 — cwd、OS、model、日期) ``` **原則**:高頻參考的內容放前面(身份、工具),低頻但重要的放後面(安全)。動態內容放最後(環境)。 ## 2. 靜態/動態邊界 ```typescript // prompts.ts 中的邊界標記 `__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__` ``` 邊界之前 = 靜態段(所有 session 共用,可全域 cache) 邊界之後 = 動態段(session 特定:cwd、日期、model 名稱) **為什麼**:如果有 N 個 boolean 條件分散在 prompt 各處,理論上會產生 2^N 個不同的 prompt 變體,每個都要獨立 cache。邊界設計把變化集中在尾部,靜態段只有一份。 ## 3. DANGEROUS_ API 命名模式 ```typescript function DANGEROUS_uncachedSystemPromptSection( content: string, _reason: string // 強制填寫原因 ): SystemPromptSection ``` **設計意圖**:把「這會破壞 prompt cache」的風險直接編碼在函式名稱裡。開發者在 code review 時看到 `DANGEROUS_` 就知道要特別審查。`_reason` 參數強制記錄為什麼需要不快取的段落。 ## 4. Eval 驅動的措辭 Claude Code 的 prompt 用詞不是靠直覺,而是量測: | 措辭決策 | 數據來源 | |----------|----------| | MEMORY.md 標題「auto memory」 | A/B eval 測試不同標題的效果 | | `NO_TOOLS_PREAMBLE` 放在 compaction prompt 最前面 | Sonnet 4.6 compaction 時 2.79% 會嘗試呼叫工具,移到最前面降回 ~0% | | Capybara v8 的 false-claim 緩解指令 | 29-30% FC rate(vs v4 的 16.7%),需要額外指令 | | `<analysis>` 草稿機制 | 讓模型在 scratchpad 思考,compaction 品質提升但不佔 context | **啟示**:

What's inside
Steps it walks through
  1. 1. Prompt 結構順序
  2. 2. 靜態/動態邊界
  3. 3. DANGEROUS API 命名模式
  4. 4. Eval 驅動的措辭
  5. 5. Compaction Prompt 三模式
  6. 6. 安全指令三層結構
  7. 7. Top 8 Prompt 設計模式
  8. 參考
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the cc-prompt-craft skill do?

System Prompt 工程 — 基於 Claude Code 914 行系統提示詞的逆向分析。Use when: 撰寫 system prompt、設計 prompt 動態組裝、最佳化 prompt cache 效率、撰寫安全指令。

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill cc-prompt-craft --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going