Token导航 LogoToken导航TokenDH.com
前端设计只读github未标认证来源可访问许可证需确认审计通过

clean-code-developer干净的代码开发人员

Agent Skill

clean-code-developer 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合在 Codex、Claude、Cursor、Gemini CLI 中希望让 Agent 持续沉淀问题、修正和最佳实践时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

840

周安装

35

GitHub Stars

7

下载量

280
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:clean-code-developer(干净的代码开发人员)
来源仓库:https://github.com/d-o-hub/rust-self-learning-memory
仓库路径:skills/clean-code-developer
安装命令:
npx skills add https://github.com/d-o-hub/rust-self-learning-memory --skill clean-code-developer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/d-o-hub/rust-self-learning-memory --skill clean-code-developer

简介

clean-code-developer 记录任务执行中的错误与经验,帮助持续改进编码实践。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中沉淀最佳实践与能力缺口时使用。
  • 通过 GitHub 安装,命令为 npx skills add https://github.com/d-o-hub/rust-self-learning-memory --skill clean-code-developer。
  • 使用前需确认本地存储路径与日志格式,注意隐私与数据安全。
  • 建议结合来源仓库和 README 文档进一步核验具体功能和使用细节。

SKILL.md

Clean Code Development

Systematic approach to writing clean, maintainable code through software engineering best practices.

Purpose

Apply SOLID principles, eliminate code duplication, maintain simplicity, and write code that reads like well-written prose.

When to Use

Use this skill when:

  • Code Reviews: Reviewing code for adherence to clean code principles
  • Refactoring: Improving existing code structure and maintainability
  • Coding Standards: Enforcing consistent coding practices and conventions
  • Clean Code Guidance: Seeking advice on clean code principles and patterns
  • Quality Checks: Integrating automated quality checks into workflows

Core Principles

SOLID Principles

Single Responsibility Principle

  • Each function/module has one reason to change
  • Clear, focused purpose
  • Easy to test and maintain

Open-Closed Principle

  • Open for extension, closed for modification
  • Use interfaces/traits for abstraction
  • New behavior through composition, not modification

Liskov Substitution Principle

  • Subtypes must be substitutable for base types
  • Derived classes should enhance functionality
  • Don't break expected behavior

Interface Segregation Principle

  • Clients shouldn't depend on interfaces they don't use
  • Small, focused interfaces
  • Prefer composition over large interfaces

Dependency Inversion Principle

  • Depend on abstractions, not concretions
  • High-level modules shouldn't depend on low-level modules
  • Use dependency injection

Other Key Principles

DRY (Don't Repeat Yourself)

  • Extract common code into reusable functions/modules
  • Avoid duplication through abstraction
  • One source of truth for each piece of logic

KISS (Keep It Simple, Stupid)

  • Simple solutions over complex ones
  • Avoid over-engineering
  • Clear, straightforward code

YAGNI (You Aren't Gonna Need It)

  • Don't build for hypothetical future requirements
  • Implement what's needed now
  • Defer complexity until necessary

Boy Scout Rule

  • Leave code better than you found it
  • Small improvements add up
  • Prevent technical debt accumulation

Code Quality Assessment

Readability

  • Self-documenting code
  • Clear, descriptive names
  • Logical flow
  • Appropriate comments

Maintainability

  • Easy to understand
  • Easy to modify
  • Easy to test
  • Clear structure

Testability

  • Dependencies easily mocked
  • Pure functions where possible
  • Clear inputs and outputs
  • Testable in isolation

Extensibility

  • Open for extension
  • Closed for modification
  • Plugin points where appropriate
  • Flexible design

Refactoring Techniques

Extract Method/Function

  • Replace duplicated code with method call
  • Name methods by what they do
  • Keep methods small and focused

Extract Class/Module

  • Group related functionality
  • Create coherent abstractions
  • Separate concerns

Replace Conditional with Polymorphism

  • Use strategy pattern for conditionals
  • Eliminate type checking
  • Improve extensibility

Introduce Parameter Object

  • Reduce parameter count
  • Group related parameters
  • Improve method signatures

Decompose Conditional

  • Simplify complex conditions
  • Extract boolean expressions
  • Improve readability

Anti-Patterns to Avoid

Code Smells

  • Long Method: Break into smaller methods
  • Long Parameter List: Use parameter objects
  • Duplicate Code: Extract to reusable functions
  • Large Class: Split into smaller classes
  • God Class: Reduce responsibilities
  • Feature Envy: Move methods to appropriate classes
  • Data Clumps: Group related data
  • Primitive Obsession: Use value objects
  • Switch Statements: Use polymorphism/strategy pattern
  • Temporary Field: Eliminate through parameter passing
  • Refused Bequest: Pass parameters explicitly

Rust-Specific Issues

  • Excessive Clone: Use borrowing or Arc
  • Unnecessary Unwrap: Use proper error handling with ?
  • Deep Nesting: Extract methods to flatten
  • Large Functions: Split into smaller, focused functions (< 50 LOC)
  • Unsafe Code: Only when necessary, well-documented
  • Memory Leaks: Proper ownership and borrowing
  • Deadlocks: Release locks before .await

Integration with Development Workflows

Pre-Commit Hooks

  • Run formatting (rustfmt)
  • Run linting (clippy)
  • Run basic tests
  • Check for common anti-patterns

CI/CD Integration

  • Automated formatting checks
  • Linting with warnings as errors
  • Test coverage requirements
  • Code quality metrics

Code Review Checklist

  • Follows SOLID principles
  • No code duplication
  • Appropriate naming conventions
  • Proper error handling
  • Comprehensive tests
  • Clear documentation

Best Practices

DO:

✓ Apply SOLID principles consistently ✓ Extract common code into reusable functions ✓ Keep functions small and focused (< 50 LOC) ✓ Use descriptive names that reveal intent ✓ Write tests before refactoring (TDD) ✓ Document complex business logic, not obvious code ✓ Use static analysis tools (clippy, SonarQube) ✓ Leave code better than you found it ✓ Prefer composition over inheritance ✓ Keep dependencies minimal and explicit

DON'T:

✗ Violate SOLID principles ✗ Duplicate code "for now" - fix immediately ✗ Write functions longer than 50 lines without strong justification ✗ Use abbreviations or unclear names ✗ Refactor without adequate test coverage ✗ Over-document obvious code ✗ Skip static analysis warnings ✗ Over-engineer simple problems ✗ Create tight coupling between modules

Metrics

Track these metrics to assess code quality:

  • Cyclomatic Complexity: Average < 10 per function
  • Lines of Code: < 500 per file (project standard)
  • Function Length: < 50 lines average
  • Test Coverage: > 90% line coverage
  • Code Duplication: < 5%
  • Technical Debt Ratio: Trend downward over time

Examples

Example 1: Extract Method

// BEFORE - Code smell: duplicate logic
fn process_data_a(data: &Data) -> Result<Output> {
    // Validation
    if data.id.is_empty() {
        return Err(anyhow!("ID is required"));
    }
    if data.value < 0 {
        return Err(anyhow!("Value must be positive"));
    }
    // Processing
    let result = calculate(data);
    Ok(result)
}

fn process_data_b(data: &Data) -> Result<Output> {
    // Same validation code duplicated
    if data.id.is_empty() {
        return Err(anyhow!("ID is required"));
    }
    if data.value < 0 {
        return Err(anyhow!("Value must be positive"));
    }
    // Processing
    let result = calculate(data);
    Ok(result)
}
// AFTER - Applied DRY principle
fn validate_data(data: &Data) -> Result<()> {
    if data.id.is_empty() {
        return Err(anyhow!("ID is required"));
    }
    if data.value < 0 {
        return Err(anyhow!("Value must be positive"));
    }
    Ok(())
}

fn process_data_a(data: &Data) -> Result<Output> {
    validate_data(data)?;
    let result = calculate(data);
    Ok(result)
}

fn process_data_b(data: &Data) -> Result<Output> {
    validate_data(data)?;
    let result = calculate(data);
    Ok(result)
}

Example 2: Single Responsibility Principle

// BEFORE - Single function doing too much
pub fn handle_user_request(data: UserData) -> Result<UserResult> {
    // Validate
    validate_user(&data)?;
    // Store in database
    db::save_user(&data)?;
    // Send email
    email::send_welcome(&data.email)?;
    // Calculate recommendations
    let recs = calculate_recommendations(&data)?;
    Ok(UserResult {
        saved: true,
        recommendations: recs,
    })
}
// AFTER - Split responsibilities
pub struct UserHandler {
    db: Arc<Database>,
    email: Arc<EmailService>,
    recommender: Arc<RecommenderService>,
}

impl UserHandler {
    pub async fn handle_user_request(&self, data: UserData) -> Result<UserResult> {
        // Each function has single responsibility
        self.validate_user(&data)?;
        self.save_user(&data).await?;
        self.send_welcome_email(&data.email).await?;
        let recs = self.get_recommendations(&data).await?;

        Ok(UserResult {
            saved: true,
            recommendations: recs,
        })
    }

    fn validate_user(&self, data: &UserData) -> Result<()> {
        // Validation logic
        Ok(())
    }

    async fn save_user(&self, data: &UserData) -> Result<()> {
        self.db.save_user(data).await
    }

    async fn send_welcome_email(&self, email: &str) -> Result<()> {
        self.email.send_welcome(email).await
    }

    async fn get_recommendations(&self, data: &UserData) -> Result<Vec<Recommendation>> {
        self.recommender.calculate(data).await
    }
}

Integration with Skills

Complements:

  • rust-code-quality: For Rust-specific quality checks
  • code-reviewer: For comprehensive code review workflows
  • test-runner: For testing refactored code

Invokes:

  • quality-unit-testing: For testing best practices

Tools and Commands

Static Analysis

# Clippy - Rust linter
./scripts/code-quality.sh clippy --workspace

# Check for specific issues
cargo clippy -- -W clippy::too_many_arguments
cargo clippy -- -W clippy::unwrap_used

Complexity Analysis

# Install complexity tool
cargo install cargo-complexity

# Analyze complexity
cargo complexity

Duplication Detection

# Use tools like jscpd, SonarQube, or custom scripts
# Find duplicated code blocks

Quality Gates

Ensure code passes these quality gates:

  • Formatting: 100% rustfmt compliant
  • Linting: Zero clippy warnings
  • Complexity: Cyclomatic complexity < 10 per function
  • Test Coverage: > 90% line coverage
  • Duplication: < 5% duplicate code
  • Documentation: All public APIs documented

Continuous Improvement

Weekly Reviews

  • Review code quality metrics
  • Identify trends and issues
  • Update coding standards if needed
  • Refactor technical debt

Retrospectives

  • Analyze what worked well
  • Identify common issues
  • Improve guidelines
  • Share learnings with team

Summary

Clean code development produces software that is:

  • Readable: Easy to understand by others
  • Maintainable: Easy to modify and extend
  • Testable: Easy to write tests for
  • Efficient: Minimal technical debt
  • Reliable: Fewer bugs and issues

Apply these principles systematically to write code that stands the test of time.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.11%
按下载量换算107

Claude

28.85%
按下载量换算81

Cursor

16.92%
按下载量换算47

Gemini CLI

10.32%
按下载量换算29

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills