管理 Code Snippets

SkillDev tools

Use when you need to add, update, or delete Code Snippets for a Best Practice, providing concrete code examples of correct/incorrect usage. Trigger words: manage code snippets, add code snippet, create example code, edit code examples.

Use 管理 Code Snippets in Claude, ChatGPT or Ahel Desktop

Free. Sign in, add 管理 Code Snippets and connect your AI. About a minute.

Also: Claude Code · Cursor · Codex

Then ask your AI: use the 管理 Code Snippets skill

Details

Instructions available. Your AI can read the instructions. Execution depends on the setup they require.

Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.

管理 Code SnippetsStart free

What this skill tells your AI

The instructions your AI receives, as published by forge-town/ordine in skills/ordine-manage-codesnippet/SKILL.md and read by Ahel’s review.

概述

Code Snippet 是 Best Practice 的子资源,提供详细的代码示例(正确用法、错误用法、边界情况等)。通过 bestPracticeId 关联到所属的 Best Practice。

通过 CLI

CLI 当前不直接支持 Code Snippet CRUD。使用 REST API 操作。

通过 REST API

查看某个 Best Practice 的所有代码片段

curl -s "http://localhost:9433/api/code-snippets?bestPracticeId=bp_classname_convention" | python3 -m json.tool

添加/更新代码片段(PUT = upsert)

curl -X PUT http://localhost:9433/api/code-snippets \
  -H "Content-Type: application/json" \
  -d '{
    "id": "cs_cn_good",
    "bestPracticeId": "bp_classname_convention",
    "title": "✅ 正确用法 — cn() 函数",
    "code": "import { cn } from \"@/lib/utils\"\n\nexport function Button({ variant, className }) {\n  return (\n    <button className={cn(\n      \"px-4 py-2 rounded\",\n      variant === \"primary\" && \"bg-blue-500 text-white\",\n      className\n    )} />\n  )\n}",
    "language": "tsx",
    "sortOrder": 0
  }'

删除代码片段

curl -X DELETE "http://localhost:9433/api/code-snippets?id=cs_cn_good"

数据结构

字段类型说明
idstring唯一标识
bestPracticeIdstring所属 Best Practice ID(必填)
titlestring | null片段标题(如 "✅ 正确用法")
codestring代码内容
languagestring | null代码语言:typescript, tsx, bash, json 等
sortOrdernumber排序序号(0 开始)

编写原则

  • 至少提供一个 Good 示例和一个 Bad 示例
  • title 用 ✅/❌ emoji 标识正误
  • 代码必须语法正确、可直接使用
  • 按 sortOrder 排序:Good 在前,Bad 在后
  • language 字段便于前端语法高亮

Signals

GitHub stars
28
Forks
2
Last commit
Oct 2026
Advanced
Item type
skill
Key
ordine-manage-codesnippet
Source
github.com/forge-town/ordine