Cc Code Quality Principles logo

Cc Code Quality Principles

CommunityPopular
doccker
cc-code-quality-principles

当编写新模块、设计接口、重构代码或代码审查时触发。提供经典模块化六原则检查清单(大小适中/调用深度/扇入扇出/边界清晰/作用域内聚/可预测性),适用于 PR/Review/新模块设计场景。

Overview

Publisherdoccker
Repositorycc-use-exp
Skill namecc-code-quality-principles
Stars
1.1K
Forks
116
Bundled files
3
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 doccker on GitHub. Read the source before you install it.

Installation

Install the Cc Code Quality Principles 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/doccker/cc-use-exp/tree/main/.codex/skills/cc-code-quality-principles
  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/doccker/cc-use-exp.git /tmp/cc-use-exp
mkdir -p .claude/skills
cp -r /tmp/cc-use-exp/.codex/skills/cc-code-quality-principles .claude/skills/cc-code-quality-principles
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Cc Code Quality Principles 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 Cc Code Quality Principles 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 Cc Code Quality Principles 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.

模块化设计六原则

经典软件工程设计原则在 AI 协作场景下的现代化清单。 用作新模块设计、重构、代码审查时的对照表,不替代具体执行 skill。

触发场景

  • 编写新模块、新服务、新接口
  • 用户说"设计"、"拆分模块"、"评审"、"重构"
  • /review、/new-feature、/optimize、/design 命令在设计阶段
  • 评估技术债时对照原则定位坏味道

六原则速查表

#原则一句话衡量指标详细案例
1模块大小适中单文件控制在职责边界内行数/职责数引用 cc-size-check
2减少调用深度调用链尽量 ≤ 3 层栈深度modularity.md#调用深度
3多扇入,少扇出被复用 > 主动依赖依赖数/被依赖数modularity.md#扇入扇出
4接口边界清晰入参/出参/异常统一统一响应包装modularity.md#边界清晰
5作用域内聚改 A 不波及 B跨模块副作用引用 cc-refactor-safety
6功能可预测同输入→同输出幂等/无副作用/可测predictability.md

1. 模块大小适中

主要执行交给 cc-size-check skill;本 skill 仅作总纲提示。

核心:单文件超限是设计信号,不是格式问题。提示职责过载,应拆分。

默认阈值:Java ≤ 300 / Go ≤ 400 / Vue ≤ 200 / TS ≤ 300 / Python ≤ 300(项目可覆盖)。


2. 减少调用深度

❌ 反例:Controller → ServiceA → ServiceB → ServiceC → DAO → Mapper(6 层)。定位 bug 需要逐层进栈,新人难以理解。

✅ 正例:Controller → Service → Repository(3 层),其余通过事件/队列/纯函数解耦。

衡量:调用栈深度 > 5 即视为坏味道。详见 modularity.md#调用深度。


3. 多扇入,少扇出

❌ 反例:OrderService.createOrder() 依赖 UserService、CouponService、PaymentService、StockService、NotifyService、AuditService、CacheService、MetricsService(扇出 8)。改一处可能炸 8 处。

✅ 正例:StringUtils.toCamelCase() 被项目 30 处复用(扇入 30)。复用价值高,无下游污染。

衡量:单方法直接依赖数 ≤ 5;被依赖数越多越好。详见 modularity.md#扇入扇出。


4. 接口边界清晰 + 统一错误返回

现代化改写"单入口单出口"原则。早期 return / guard clause 优于深嵌套。

❌ 反例:成功返回 {data}、失败抛异常、还有一种返 null,调用方需要 3 种处理路径。

✅ 正例:统一 {code, data, message} 包装,异常在边界层(middleware / interceptor)集中处理。一个出入口契约对所有调用方一致。

详见 modularity.md#边界清晰。


5. 作用域内聚

主要执行交给 cc-refactor-safety 与 cc-multi-tenant-safety skill。

核心:

  • 模块内的修改不应越界影响其他模块
  • 私有实现不暴露成公共 API
  • 跨模块通信走明确的 API、事件或消息,不通过共享可变状态

6. 功能可预测

❌ 反例:

  • 同一笔 HTTP 重试扣两次款(无幂等键)
  • 定时任务跨夜失败(依赖系统时区)
  • 单测时灵时不灵(依赖外部状态)

✅ 正例:

  • 幂等键去重(写操作必有)
  • 时间统一 UTC,按需在边界转换
  • 纯函数优先,副作用集中在边界(IO/DB/网络)

详见 predictability.md。


检查清单(PR / Review 对照)

新增或修改模块前,逐条过一遍:

  • 大小:单文件未超行数限制?参考 cc-size-check
  • 深度:调用链 ≤ 3 层?没有 A→B→C→D→E 的长链?
  • 扇出:直接依赖数 ≤ 5?是否引入了过多 service?
  • 边界:接口入参/出参/异常有统一约定?
  • 作用域:修改是否越界影响了其他模块?
  • 幂等:重试/重复调用是否安全?
  • 隐式依赖:是否依赖时区、当前时间、随机数等隐式环境?

与其他 skill 的边界

原则主要执行 skill本 skill 角色
1 大小适中cc-size-check触发提示
2 调用深度无独立 skill本 skill 主导
3 扇入扇出无独立 skill本 skill 主导
4 边界清晰cc-api-design-safety决策对照
5 作用域内聚cc-refactor-safety / cc-multi-tenant-safety触发提示
6 可预测cc-time-zone-safety / cc-redis-safety / cc-query-performance-safety本 skill 主导,专项 skill 处理具体陷阱

本 skill 是总纲与决策对照表,具体执行细节在上述各 skill 内。


规则溯源

> 📋 本回复遵循:`cc-code-quality-principles` - [原则编号]

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 Cc Code Quality Principles AI skill do?

当编写新模块、设计接口、重构代码或代码审查时触发。提供经典模块化六原则检查清单(大小适中/调用深度/扇入扇出/边界清晰/作用域内聚/可预测性),适用于 PR/Review/新模块设计场景。

Why use Cc Code Quality Principles on TypingMind?

Because you install it once and use it with any model. Cc Code Quality Principles 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 Cc Code Quality Principles in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/doccker/cc-use-exp/tree/main/.codex/skills/cc-code-quality-principles. 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 Cc Code Quality Principles?

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 Cc Code Quality Principles?

As many as you like. As long as a model supports skills, you can use Cc Code Quality Principles with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Cc Code Quality Principles AI skill free?

It is published on GitHub by doccker. Check the repository for licensing terms. 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 👇