抽象原则 logo

抽象原则

Organization
microwind
抽象原则

提取事物的本质特征,忽略非本质细节,通过抽象层简化复杂系统的理解和使用。

Overview

Publishermicrowind
Repositoryai-skills
Skill name抽象原则
Stars
93
Forks
25
Bundled files
3
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.

  • 3 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/abstraction-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/abstraction-principle .claude/skills/microwind-35
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.

抽象原则 (Abstraction Principle)

概述

抽象是管理复杂性的核心工具:捕获事物的本质特征,隐藏不必要的细节,提供更简单的理解模型。

核心思想:

  • 好的抽象隐藏复杂性,暴露简单接口
  • 抽象应该稳定,不因实现变化而改变
  • 每个抽象层只处理一个复杂度级别

抽象层次

java
// 从低到高的抽象层次

// 最低层:硬件指令
// MOV AX, [address]

// 操作系统层
// read(fd, buffer, size)

// 语言运行时层
// FileInputStream.read()

// 框架层
// Files.readString(Path.of("data.txt"))

// 业务层 — 最高抽象
public class ReportService {
    public Report generateMonthlyReport(YearMonth month) {
        // 调用方不需要知道数据从哪来、如何格式化
        return reportGenerator.generate(month);
    }
}

好的抽象 vs 差的抽象

java
// ❌ 抽象泄漏:暴露了实现细节
public interface UserRepository {
    User findBySQL(String sql);                    // 暴露了数据库
    User findByMongoQuery(Document query);          // 暴露了 MongoDB
    void saveWithRetry(User user, int maxRetries);  // 暴露了重试机制
}

// ✅ 好的抽象:隐藏实现
public interface UserRepository {
    Optional<User> findById(UserId id);
    Optional<User> findByEmail(String email);
    void save(User user);
    void delete(UserId id);
}
python
# ❌ 错误的抽象级别:太高或太低
class FileProcessor:
    def process(self, data):  # 太抽象,什么都能传
        pass

class CsvFileByteProcessor:  # 太具体,名字暴露所有实现
    def process_csv_bytes_with_utf8_encoding(self, raw_bytes):
        pass

# ✅ 恰当的抽象级别
class CsvImporter:
    def import_records(self, file_path: str) -> list[Record]:
        """导入CSV文件中的记录"""
        pass

抽象设计原则

1. 依赖抽象而非具体

typescript
// ❌ 依赖具体
class OrderService {
    private mysqlDb = new MySQLConnection();
    private sendGridEmail = new SendGridClient();
}

// ✅ 依赖抽象
class OrderService {
    constructor(
        private db: Database,          // 抽象
        private mailer: EmailSender    // 抽象
    ) {}
}

2. 同一方法内保持同一抽象级别

java
// ❌ 混合抽象级别
public void processOrder(Order order) {
    // 高层抽象
    validateOrder(order);
    // 突然降到低层细节
    Connection conn = DriverManager.getConnection("jdbc:mysql://...");
    PreparedStatement ps = conn.prepareStatement("INSERT INTO orders ...");
    ps.setString(1, order.getId());
    ps.executeUpdate();
    // 又回到高层
    notifyCustomer(order);
}

// ✅ 保持一致的抽象级别
public void processOrder(Order order) {
    validateOrder(order);
    saveOrder(order);       // 隐藏数据库细节
    notifyCustomer(order);
}

何时不应该抽象

❌ 只有一个实现且不太可能变化
❌ 抽象增加的复杂度大于它简化的复杂度
❌ 为了"将来可能"而抽象(违反 YAGNI)
❌ 抽象无法完全隐藏细节(抽象泄漏)

✅ 有多个实现或预期会有
✅ 需要隔离变化(如外部依赖)
✅ 降低了理解成本
✅ 简化了测试

与其他原则的关系

原则关系
封装封装隐藏内部,抽象提取本质
DIPDIP 要求依赖抽象
OCP通过抽象实现扩展开放
KISS好的抽象简化理解,坏的抽象增加复杂

总结

抽象核心:捕获本质,隐藏细节,提供简单接口。

实践要点:

  • 抽象应该隐藏复杂性而非转移复杂性
  • 同一方法内保持一致的抽象级别
  • 不要过度抽象——抽象也有成本
  • 好的抽象让代码"像读英语一样"

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/abstraction-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 👇