Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Code Consistency

ASecurity

Maintain implementation consistency when modifying or adding code in an existing project. Use when similar logic, API usage, control flow, error handling, logging, or data processing may already exist in the repository.

32 stars
0 votes
0 copies
0 views
Added 9/22/2026
ai-agentspythonapi

Works with

api

Security Analysis

A100/100

Scanned 9/22/2026

Install to Claude Code

$npx -y skills add apexcheng/yingdao-xbot-ai-agent --skill code-consistency --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Consistency?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Code Consistency
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/apexcheng-code-consistency/badge)](https://www.skillsdirectory.com/skills/apexcheng-code-consistency)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: code-consistency
description: Maintain implementation consistency when modifying or adding code in an existing project. Use when similar logic, API usage, control flow, error handling, logging, or data processing may already exist in the repository.
---

# 代码实现一致性

修改或新增已有项目代码时,先从当前项目学习已有实现,不为同类问题重新设计另一套等价写法。

## 修改前

先搜索与当前任务相同或最接近的实现。

搜索顺序:

1. 当前文件和相邻代码。
2. 当前模块。
3. 当前项目其它模块。

重点比较:

- 使用哪个 API。
- 元素 / 数据如何查询。
- 存在性如何判断。
- 控制流使用 `if`、循环还是异常。
- 异常如何处理。
- 日志如何记录。
- 返回值和数据结构如何组织。
- 局部代码是链式调用还是保留变量。

先按业务问题找相近实现,再判断项目原本采用了什么写法;不要先决定实现方式,再只搜索支持该写法的代码。

## 有成熟先例时

场景相同时,沿用已有实现模式。

不要仅因为另一种写法同样正确,就引入第二套表达方式。

例如当前项目同类场景已经统一使用:

```python
elements = element.find_all_by_xpath(xpath)
if elements:
    ...
```

则不要无业务原因改成:

```python
try:
    element.find_by_xpath(xpath)
except Exception:
    ...
```

两种代码都可能运行,但存在性判断、API 选择和控制流已经不同。以上仅用于说明“实现漂移”,不表示所有场景都必须使用 `find_all_by_xpath`。

## 没有成熟先例时

当前项目找不到相近实现时,再按项目 `AGENTS.md` 查询知识库、真实参考项目或 API 文档。

不要为了保持一致而模仿明显错误、已经废弃或与当前场景不同的代码。

## 项目存在多种写法时

不要顺手统一整个项目。

优先级:

1. 当前文件或当前模块正在使用的成熟写法。
2. 与当前业务场景最接近的实现。
3. 项目中较新的、仍在使用的实现。

如果无法判断哪一种属于当前约定,再根据知识库选择,不扩大本次修改范围。

## 修改后

检查本次新增或修改的代码与附近同类实现。

如果出现新的 API 选择、判断方式、异常处理方式、日志模式、数据处理模式或局部代码结构,确认这种差异是否有实际业务或技术原因。

没有原因,就改回项目已有模式。

## 例外

用户明确要求重构、统一风格、替换旧模式或优化已有实现时,不机械沿用旧代码。

Attribution

apexchengapexcheng
View sourceMore from apexcheng →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Ultra-compressed communication mode that cuts output tokens while keeping technical accuracy. Levels: lite, full, ultra and the wenyan variants. Use for /caveman, "caveman mode", "talk like caveman", "be brief" or "less tokens".

1066601 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

686011 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3351 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

651 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →