一致性原则 logo

一致性原则

Organization
microwind
一致性原则

在整个系统中保持设计、命名、模式和行为的一致性,降低认知负担,提高可维护性。

Overview

Publishermicrowind
Repositoryai-skills
Skill name一致性原则
Stars
93
Forks
25
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by microwind on GitHub. Read the source before you install it.

Installation

Install the 一致性原则 AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/microwind/ai-skills/tree/main/design-principles/consistency-principle
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/microwind/ai-skills.git /tmp/ai-skills
mkdir -p .claude/skills
cp -r /tmp/ai-skills/design-principles/consistency-principle .claude/skills/microwind-38
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable 一致性原则 in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads 一致性原则 on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so 一致性原则 is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

一致性原则 (Consistency Principle)

概述

一致性原则:相似的问题用相似的方式解决,相同的概念用相同的名称表达。一致性降低了认知负担,让开发者能凭直觉理解新代码。

一致性维度:

  • 命名一致 - 相同概念用相同的词
  • 模式一致 - 相似问题用相同的设计模式
  • 风格一致 - 代码格式、结构统一
  • 行为一致 - 相似的API有相似的行为

命名一致性

java
// ❌ 不一致的命名
public class UserService {
    public User getUser(Long id);           // get
    public Order fetchOrder(Long id);       // fetch
    public Product retrieveProduct(Long id); // retrieve
    public Invoice findInvoice(Long id);    // find
    // 四个不同的词表达同一含义
}

// ✅ 一致命名
public class UserService {
    public User findById(Long id);
}
public class OrderService {
    public Order findById(Long id);
}
public class ProductService {
    public Product findById(Long id);
}
python
# ❌ 不一致的错误处理
class UserService:
    def create_user(self, data):
        return None  # 失败返回 None

class OrderService:
    def create_order(self, data):
        raise ValueError("创建失败")  # 失败抛异常

class PaymentService:
    def create_payment(self, data):
        return {"success": False, "error": "失败"}  # 失败返回错误对象

# ✅ 一致的错误处理策略
# 团队约定:业务异常统一抛自定义异常
class UserService:
    def create_user(self, data):
        if not data.get("email"):
            raise ValidationError("邮箱不能为空")

class OrderService:
    def create_order(self, data):
        if not data.get("items"):
            raise ValidationError("订单项不能为空")

模式一致性

typescript
// ✅ 所有 API 端点遵循相同的模式
// 请求格式一致
interface ApiResponse<T> {
    code: number;
    data: T;
    message: string;
}

// 错误处理一致
app.get('/api/users/:id', async (req, res) => {
    const user = await userService.findById(req.params.id);
    if (!user) return res.status(404).json({ code: 404, data: null, message: '用户不存在' });
    return res.json({ code: 200, data: user, message: 'ok' });
});

app.get('/api/orders/:id', async (req, res) => {
    const order = await orderService.findById(req.params.id);
    if (!order) return res.status(404).json({ code: 404, data: null, message: '订单不存在' });
    return res.json({ code: 200, data: order, message: 'ok' });
});

一致性检查清单

□ 相同操作在不同模块中用相同的方法名
□ 错误处理策略全项目统一
□ API 响应格式统一
□ 日志格式和级别使用规范一致
□ 目录结构在各模块间一致
□ 数据库命名规范一致(snake_case vs camelCase)
□ 时间格式统一(UTC vs 本地时区)
□ 配置方式统一(环境变量 vs 配置文件)

何时打破一致性

✅ 有充分理由时可以例外:
- 性能瓶颈要求特殊实现
- 第三方库强制了不同的模式
- 新的最佳实践明显优于现有惯例

⚠️ 打破一致性时:
- 记录原因(ADR 或代码注释)
- 通知团队
- 评估是否应该全局迁移到新模式

与其他原则的关系

原则关系
KISS一致性降低认知负担,保持简单
DRY模式一致有助于发现和消除重复
最少知识一致的接口减少需要了解的知识

总结

一致性核心:相似问题用相似方案,降低认知负担。

实践要点:

  • 建立并遵循团队编码规范
  • 命名、模式、错误处理全项目统一
  • 新代码参考现有代码的模式
  • 有充分理由时可以例外,但需记录

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the 一致性原则 AI skill do?

在整个系统中保持设计、命名、模式和行为的一致性,降低认知负担,提高可维护性。

Why use 一致性原则 on TypingMind?

Because you install it once and use it with any model. 一致性原则 is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install 一致性原则 in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/microwind/ai-skills/tree/main/design-principles/consistency-principle. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use 一致性原则?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with 一致性原则?

As many as you like. As long as a model supports skills, you can use 一致性原则 with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the 一致性原则 AI skill free?

Yes. It is published on GitHub by microwind under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇