欢迎使用Markdown编辑器

🏗️ 提示词架构总览
Claude Code 的系统提示词采用 分层设计,核心思路是:

┌─────────────────────────────────────────────┐
│ 静态内容(可全局缓存) │
├─────────────────────────────────────────────┤
│ SYSTEM_PROMPT_DYNAMIC_BOUNDARY │
├─────────────────────────────────────────────┤
│ 动态内容(会话特定) │
└─────────────────────────────────────────────┘
这个边界设计非常精妙——静态部分可以复用,极大降低了 API 缓存失效率。

📖 第一层:核心身份与任务定义
基础介绍
You are an interactive agent that helps users with software engineering tasks.
Use the instructions below and the tools available to you to assist the user.

IMPORTANT: You must NEVER generate or guess URLs for the user unless you are
confident that the URLs are for helping the user with programming.
设计意图:明确角色定位,同时划定安全边界(不随意生成 URL)。

🔧 第二层:系统运作机制

System

  • All text you output outside of tool use is displayed to the user.
  • Tools are executed in a user-selected permission mode.
  • Tool results and user messages may include tags.
  • The system will automatically compress prior messages as it approaches context limits.
    核心要点:

告知模型输出机制(tool call vs 文本输出)
引入权限模式概念
说明上下文压缩机制(突破长度限制)
💻 第三层:任务执行准则

Doing tasks

  • The user will primarily request you to perform software engineering tasks:
    • solving bugs, adding new functionality, refactoring code, explaining code…
  • You are highly capable and often allow users to complete ambitious tasks.
  • In general, do not propose changes to code you haven’t read.
  • Do not create files unless they’re absolutely necessary.
  • Be careful not to introduce security vulnerabilities such as command injection,
    XSS, SQL injection, and other OWASP top 10 vulnerabilities.
    设计亮点:

强调「先读代码再改代码」
防止文件膨胀(不必要的创建)
安全第一的底线
🔥 代码风格约束(关键!)

代码风格

  • Don’t add features, refactor code, or make “improvements” beyond what was asked.
  • Don’t add error handling, fallbacks, or validation for scenarios that can’t happen.
  • Don’t create helpers, utilities, or abstractions for one-time operations.
  • Don’t add docstrings, comments, or type annotations to code you didn’t change.
  • Default to writing no comments. Only add one when the WHY is non-obvious.
  • Don’t explain WHAT the code does, since well-named identifiers already do that.
    💡 解读:这些约束直接针对 AI 的「过度工程化」倾向——不让你做额外的美化、抽象、注释,只解决实际问题。

⚡ 第四层:行动安全边界

Executing actions with care

Carefully consider the reversibility and blast radius of actions.

  • Local, reversible actions like editing files or running tests: OK
  • Hard-to-reverse or risky actions: CHECK WITH USER FIRST

Examples of risky actions:

  • Destructive: deleting files/branches, dropping database tables, rm -rf
  • Hard-to-reverse: force-pushing, git reset --hard, amending published commits
  • Visible to others: pushing code, creating/closing PRs, sending messages
    设计哲学:

默认需要确认的风险行动
明确列出「危险操作」清单
强调「三思而后行」
🔨 第五层:工具使用规范

Using your tools

  • To read files use Read instead of cat, head, tail, or sed
  • To edit files use Edit instead of sed or awk
  • To create files use Write instead of cat with heredoc or echo redirection
  • Reserve using Bash exclusively for system commands

You can call multiple tools in a single response. Maximize use of parallel
tool calls where possible to increase efficiency.
核心原则:

专用工具优先于通用命令
充分利用并行调用提升效率
🎨 第六层:输出风格

Tone and style

  • Only use emojis if the user explicitly requests it.
  • Your responses should be short and concise.
  • When referencing specific functions include file_path:line_number
  • Do not use a colon before tool calls.

Output efficiency

IMPORTANT: Go straight to the point. Try the simplest approach first.
Keep your text output brief and direct.
Focus on:

  • Decisions that need the user’s input
  • High-level status updates at natural milestones
  • Errors or blockers that change the plan
    简洁主义:这直接压缩了响应长度,提升交互效率。

🌊 动态内容层(边界后)
环境信息

Environment

You have been invoked in the following environment:

  • Primary working directory: /path/to/cwd
  • Is a git repository: Yes/No
  • Platform: darwin
  • Shell: zsh
  • OS Version: Darwin 23.0.0

You are powered by the model named Claude Sonnet 4.6.
The exact model ID is claude-sonnet-4-6-20250501.
Assistant knowledge cutoff is August 2025.
MCP 服务器指令

MCP Server Instructions

The following MCP servers have provided instructions for how to use their tools…

server-name

[服务器提供的具体指令]
临时目录

Scratchpad Directory

IMPORTANT: Always use this scratchpad directory for temporary files:
/tmp/claude-scratchpad-xxx
🔐 内部版本特供(Ant-only)
代码中存在条件编译,针对内部版本(Ant)有额外约束:

…(process.env.USER_TYPE === ‘ant’
? [
Default to writing no comments. Only add one when the WHY is non-obvious...,
If you notice the user's request is based on a misconception, say so...,
Report outcomes faithfully: if tests fail, say so with the relevant output...,
]
: [])
内部版本的额外要求:

禁止不必要的注释
主动指出用户的误解
如实报告测试结果,不「美化」输出
📊 缓存优化设计
缓存键设计
export const SYSTEM_PROMPT_DYNAMIC_BOUNDARY = ‘SYSTEM_PROMPT_DYNAMIC_BOUNDARY
设计原理:

边界之前:静态内容 → 可全局缓存 (scope: ‘global’)
边界之后:动态内容 → 会话特定,不能缓存
这意味着同一个组织下的多个用户共享相同的静态前缀,极大提高了缓存命中率。

🧠 架构设计洞察

  1. 约束而非诱导
    传统 Prompt 倾向于「请尽量…」「建议…」,而 Claude Code 采用「不要…」「避免…」的约束式语言。这更有效——AI 更容易遵守边界。

  2. 渐进式披露
    不是一次性给出所有规则,而是分层次:核心身份 → 行为准则 → 具体工具 → 输出风格。

  3. 动态边界
    利用 SYSTEM_PROMPT_DYNAMIC_BOUNDARY 实现缓存与灵活性的平衡,这是工程实践的精髓。

  4. 条件编译
    使用 feature(‘FEATURE_NAME’) 实现特性开关,让不同版本共存同一代码库。

📝 总结
Claude Code 的系统提示词设计展示了一个成熟 AI 编程助手的自我修养:

维度 设计原则
能力 强调「先读后改」,专用工具优先
边界 风险行动需确认,安全漏洞零容忍
效率 简洁输出,聚焦决策点
风格 无注释、少 emoji、代码引用带行号
工程 缓存分层、条件编译、动态边界
这套提示词不是「写出来」的,而是通过无数轮实际使用反馈迭代出来的。如果你正在构建 AI 编程助手,这是一份绝佳的参考蓝图。
你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。

新的改变

我们对Markdown编辑器进行了一些功能拓展与语法支持,除了标准的Markdown编辑器功能,我们增加了如下几点新功能,帮助你用它写博客:

  1. 全新的界面设计 ,将会带来全新的写作体验;
  2. 在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样式 进行展示;
  3. 增加了 图片拖拽 功能,你可以将本地的图片直接拖拽到编辑区域直接展示;
  4. 全新的 KaTeX数学公式 语法;
  5. 增加了支持甘特图的mermaid语法1 功能;
  6. 增加了 多屏幕编辑 Markdown文章功能;
  7. 增加了 焦点写作模式、预览模式、简洁写作模式、左右区域同步滚轮设置 等功能,功能按钮位于编辑区域与预览区域中间;
  8. 增加了 检查列表 功能。

功能快捷键

撤销:Ctrl/Command + Z
重做:Ctrl/Command + Y
加粗:Ctrl/Command + B
斜体:Ctrl/Command + I
标题:Ctrl/Command + Shift + H
无序列表:Ctrl/Command + Shift + U
有序列表:Ctrl/Command + Shift + O
检查列表:Ctrl/Command + Shift + C
插入代码:Ctrl/Command + Shift + K
插入链接:Ctrl/Command + Shift + L
插入图片:Ctrl/Command + Shift + G
查找:Ctrl/Command + F
替换:Ctrl/Command + G

合理的创建标题,有助于目录的生成

直接输入1次#,并按下space后,将生成1级标题。
输入2次#,并按下space后,将生成2级标题。
以此类推,我们支持6级标题。有助于使用TOC语法后生成一个完美的目录。

如何改变文本的样式

强调文本 强调文本

加粗文本 加粗文本

标记文本

删除文本

引用文本

H2O is是液体。

210 运算结果是 1024.

插入链接与图片

链接: link.

图片: Alt

带尺寸的图片: Alt

居中的图片: Alt

居中并且带尺寸的图片: Alt

当然,我们为了让用户更加便捷,我们增加了图片拖拽功能。

如何插入一段漂亮的代码片

博客设置页面,选择一款你喜欢的代码片高亮样式,下面展示同样高亮的 代码片.

// An highlighted block
var foo = 'bar';

生成一个适合你的列表

  • 项目
    • 项目
      • 项目
  1. 项目1
  2. 项目2
  3. 项目3
  • 计划任务
  • 完成任务

创建一个表格

一个简单的表格是这么创建的:

项目 Value
电脑 $1600
手机 $12
导管 $1

设定内容居中、居左、居右

使用:---------:居中
使用:----------居左
使用----------:居右

第一列 第二列 第三列
第一列文本居中 第二列文本居右 第三列文本居左

SmartyPants

SmartyPants 是一个文本转换工具,主要功能是将普通的 ASCII 标点符号自动转换为更美观的印刷体标点符号。例如:

原始符号 转换后 说明
"引号" “引号” 直引号变弯引号
'单引号' ‘单引号’ 直单引号变弯单引号
-- 两个连字符变短破折号
--- 三个连字符变长破折号
... 三个点变省略号

创建一个自定义列表

Markdown
Text-to- HTML conversion tool
Authors
John
Luke

如何创建一个注脚

一个具有注脚的文本。2

注释也是必不可少的

Markdown将文本转换为 HTML

KaTeX数学公式

您可以使用渲染LaTeX数学表达式 KaTeX:

Gamma公式展示 Γ ( n ) = ( n − 1 ) ! ∀ n ∈ N \Gamma(n) = (n-1)!\quad\forall n\in\mathbb N Γ(n)=(n1)!nN 是通过欧拉积分

Γ ( z ) = ∫ 0 ∞ t z − 1 e − t d t   . \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. Γ(z)=0tz1etdt.

你可以找到更多关于的信息 LaTeX 数学表达式here.

新的甘特图功能,丰富你的文章

2014-01-07 2014-01-09 2014-01-11 2014-01-13 2014-01-15 2014-01-17 2014-01-19 2014-01-21 已完成 进行中 计划一 计划二 现有任务 Adding GANTT diagram functionality to mermaid
  • 关于 甘特图 语法,参考 这儿,

UML图表

可以使用UML图表进行渲染,例如下面产生的一个序列图:

王五 李四 张三 王五 李四 张三 李四想了很长时间, 文字太长了 不适合放在一行. 你好!李四, 最近怎么样? 你最近怎么样,王五? 我很好,谢谢! 我很好,谢谢! 打量着王五... 很好... 王五, 你怎么样?
  • 关于 UML图表 语法,参考 这儿,

流程图

链接

长方形

圆角长方形

菱形

  • 关于 Mermaid 语法,参考 这儿,

FLowchart流程图

我们依旧会支持flowchart.js的流程图语法:

Created with Raphaël 2.3.0 开始 我的操作 确认? 结束 yes no
  • 关于 Flowchart流程图 语法,参考 这儿.

导出与导入

导出

如果你想尝试使用此编辑器, 你可以在此篇文章任意编辑。当你完成了一篇文章的写作, 在上方工具栏找到 文章导出 ,生成一个.md文件或者.html文件进行本地保存。

导入

如果你想加载一篇你写过的.md文件,在上方工具栏可以选择导入功能进行对应扩展名的文件导入,
继续你的创作。


  1. mermaid语法说明 ↩︎

  2. 注脚的解释 ↩︎

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐