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

coding-standards编码标准

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

192

周安装

8

GitHub Stars

2

下载量

64
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:coding-standards(编码标准)
来源仓库:https://github.com/knowlet/skills
仓库路径:skills/coding-standards
安装命令:
npx skills add https://github.com/knowlet/skills --skill coding-standards
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/knowlet/skills --skill coding-standards

简介

coding-standards 用于辅助前端页面、组件、样式和交互逻辑的开发与维护。

  • 适合生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码。
  • 需结合项目现有设计系统和构建方式使用,避免孤立片段。
  • 涉及页面改动时应配合本地预览和构建检查确认效果。
  • 建议保留项目原有事实与结构,不擅自修改核心配置。

SKILL.md

Coding Standards Skill

觸發時機

  • 編寫新代碼時
  • 代碼審查階段
  • 生成 Application Service / Use Case 時
  • 被 Sub-agent (command/query/reactor) 呼叫時

核心任務

強制執行統一的編碼規範,確保 AI 生成的代碼風格高度一致,降低人類審閱成本。

多語言支援

根據專案語言選擇對應的規範:

語言參考文件說明
Java本文件Spring Boot / Jakarta EE
Javareferences/JAVA_CLEAN_ARCH.mdClean Architecture 詳細結構
TypeScriptreferences/TYPESCRIPT.mdNode.js / Deno / Bun
Goreferences/GOLANG.mdStandard Go Project Layout
Rustreferences/RUST.mdCargo / Tokio async runtime

Claude Code Sub-agent 整合

當被其他 Sub-agent 呼叫時,本 Skill 提供語言特定的編碼規範:

command-sub-agent 呼叫 → 提供 Use Case / Command Handler 的編碼規範
query-sub-agent 呼叫 → 提供 Query Handler / Read Model 的編碼規範
reactor-sub-agent 呼叫 → 提供 Event Handler 的編碼規範

規範 1:Input/Output Inner Class 模式

目的

  • 明確定義方法的輸入輸出契約
  • 提高代碼可讀性和可維護性
  • 便於單元測試

標準模式

public class CreateOrderUseCase {

    // ✅ Input 定義為靜態內部類別
    public static class Input {
        private final CustomerId customerId;
        private final List<OrderItemRequest> items;
        private final ShippingAddress address;

        public Input(CustomerId customerId,
                     List<OrderItemRequest> items,
                     ShippingAddress address) {
            // 可在此進行基本驗證
            Objects.requireNonNull(customerId, "customerId must not be null");
            Objects.requireNonNull(items, "items must not be null");
            if (items.isEmpty()) {
                throw new IllegalArgumentException("items must not be empty");
            }
            this.customerId = customerId;
            this.items = List.copyOf(items);
            this.address = address;
        }

        // Getters
        public CustomerId getCustomerId() { return customerId; }
        public List<OrderItemRequest> getItems() { return items; }
        public ShippingAddress getAddress() { return address; }
    }

    // ✅ Output 定義為靜態內部類別
    public static class Output {
        private final OrderId orderId;
        private final OrderStatus status;
        private final LocalDateTime createdAt;

        public Output(OrderId orderId, OrderStatus status, LocalDateTime createdAt) {
            this.orderId = orderId;
            this.status = status;
            this.createdAt = createdAt;
        }

        // Getters
        public OrderId getOrderId() { return orderId; }
        public OrderStatus getStatus() { return status; }
        public LocalDateTime getCreatedAt() { return createdAt; }
    }

    // ✅ 主要執行方法,接收 Input,回傳 Output
    public Output execute(Input input) {
        // 業務邏輯
    }
}

禁止模式

// ❌ 禁止:直接使用多個參數
public OrderResult createOrder(String customerId, List<Item> items, String address) {
    // 這樣做會讓介面難以維護
}

// ❌ 禁止:使用 Map 作為輸入輸出
public Map<String, Object> createOrder(Map<String, Object> params) {
    // 這樣做會失去型別安全
}

規範 2:@Bean not @Component

目的

  • 集中管理依賴注入配置
  • 明確的依賴關係可視化
  • 便於測試時替換實作

標準模式

// ✅ 正確:使用 @Configuration + @Bean
@Configuration
public class UseCaseConfiguration {

    @Bean
    public CreateOrderUseCase createOrderUseCase(
            OrderRepository orderRepository,
            InventoryService inventoryService,
            EventPublisher eventPublisher) {
        return new CreateOrderUseCase(
            orderRepository,
            inventoryService,
            eventPublisher
        );
    }

    @Bean
    public CancelOrderUseCase cancelOrderUseCase(
            OrderRepository orderRepository,
            PaymentGateway paymentGateway) {
        return new CancelOrderUseCase(orderRepository, paymentGateway);
    }
}

// ✅ Use Case 類別保持純淨,無 Spring 註解
public class CreateOrderUseCase {
    private final OrderRepository orderRepository;
    private final InventoryService inventoryService;
    private final EventPublisher eventPublisher;

    // 建構子注入
    public CreateOrderUseCase(
            OrderRepository orderRepository,
            InventoryService inventoryService,
            EventPublisher eventPublisher) {
        this.orderRepository = orderRepository;
        this.inventoryService = inventoryService;
        this.eventPublisher = eventPublisher;
    }
}

禁止模式

// ❌ 禁止:在 Use Case 上使用 @Component/@Service
@Service  // ❌ 不要這樣做
public class CreateOrderUseCase {

    @Autowired  // ❌ 不要這樣做
    private OrderRepository orderRepository;
}

例外情況

以下情況可使用 @Component 系列註解:

類型允許使用說明
Controller@RestController展示層入口點
Repository 實作@RepositoryInfrastructure 層
Event Listener@Component技術性元件
Scheduled Task@Component技術性元件

規範 3:命名規範

Use Case / Command Handler 命名

// ✅ 動詞 + 名詞 + UseCase
CreateOrderUseCase
CancelOrderUseCase
UpdateCustomerProfileUseCase

// ✅ CQRS Command Handler
CreateOrderCommandHandler
CancelOrderCommandHandler

// ✅ CQRS Query Handler
GetOrderByIdQueryHandler
ListOrdersByCustomerQueryHandler

方法命名

// ✅ Use Case 統一使用 execute()
public Output execute(Input input)

// ✅ Command Handler 統一使用 handle()
public void handle(CreateOrderCommand command)

// ✅ Query Handler 統一使用 handle()
public OrderDto handle(GetOrderByIdQuery query)

規範 4:不可變物件 (Immutable Objects)

Input/Output 必須是不可變的

public static class Input {
    private final CustomerId customerId;  // ✅ final
    private final List<OrderItemRequest> items;

    public Input(CustomerId customerId, List<OrderItemRequest> items) {
        this.customerId = customerId;
        this.items = List.copyOf(items);  // ✅ 防禦性複製
    }

    // ✅ 只有 Getter,沒有 Setter
    public CustomerId getCustomerId() { return customerId; }
    public List<OrderItemRequest> getItems() {
        return items;  // 已經是不可變的
    }
}

規範 5:例外處理模式

使用 Domain Exception

// ✅ 定義領域特定例外
public class OrderNotFoundException extends DomainException {
    public OrderNotFoundException(OrderId orderId) {
        super("Order not found: " + orderId.getValue());
    }
}

public class InsufficientInventoryException extends DomainException {
    public InsufficientInventoryException(ProductId productId, int requested, int available) {
        super(String.format(
            "Insufficient inventory for product %s: requested %d, available %d",
            productId.getValue(), requested, available
        ));
    }
}

檢查清單

新增 Use Case 時

  • 是否定義了 Input 內部類別?
  • 是否定義了 Output 內部類別?
  • Input/Output 是否為不可變?
  • 是否使用 @Bean 而非 @Component?
  • 命名是否遵循規範?

代碼審查時

  • 有無 @Autowired 欄位注入?(應改用建構子注入)
  • Use Case 類別是否有框架依賴?
  • 例外是否使用 Domain Exception?

自動檢查規則 (供 Linter 使用)

rules:
  - id: no-component-on-usecase
    pattern: "@(Component|Service).*class.*UseCase"
    message: "Use @Bean configuration instead of @Component on UseCase classes"
    severity: error

  - id: no-autowired-field
    pattern: "@Autowired\\s+private"
    message: "Use constructor injection instead of field injection"
    severity: error

  - id: require-input-output-class
    pattern: "class.*UseCase.*execute\\((?!Input)"
    message: "UseCase.execute() should accept Input inner class"
    severity: warning

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

补充不同宿主或平台的使用分布数据

能力 5

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

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

平台分布

trae

30.3%
按下载量换算19

Claude Code

23.03%
按下载量换算15

windsurf

18.19%
按下载量换算12

OpenCode

12.51%
按下载量换算8

weavefox

9.35%
按下载量换算6

Codex

4.08%
按下载量换算3

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

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

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills