Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计异常

apex-class顶尖级

Agent Skill

apex-class 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

326

周安装

14

GitHub Stars

228

下载量

114
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/forcedotcom/afv-library --skill apex-class

简介

apex-class 用于生成结构良好、可直接投入生产的 Salesforce Apex 类代码。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中开发服务层、查询封装、批处理或队列化逻辑时使用。
  • 可生成 Service、Selector、Domain、Batch、Queueable、Schedulable 等类别的 Apex 代码,但不包括触发器和单元测试。
  • 安装前请确认权限范围和维护状态,避免触发不必要的联网或文件操作。
  • 建议结合原始 README 和项目实际需求核验输出是否符合业务语义和安全规范。

SKILL.md

Apex Class

Generate well-structured, production-ready Apex classes for Salesforce development.

Scope

Generates:

  • Service classes (business logic layer)
  • Selector / query classes (SOQL encapsulation)
  • Domain classes (SObject-specific logic)
  • Batch Apex classes (Database.Batchable)
  • Queueable Apex classes (Queueable, optionally Finalizer)
  • Schedulable Apex classes (Schedulable)
  • DTO / wrapper / request-response classes
  • Utility / helper classes
  • Custom exception classes
  • Interfaces and abstract classes

Does NOT generate:

  • Triggers (use a trigger framework skill)
  • Unit tests (use a test writer skill)
  • Aura controllers
  • LWC JavaScript controllers

Gathering Requirements

Before generating code, gather these inputs from the user (ask if not provided):

  1. Class type — Service, Selector, Batch, Queueable, Schedulable, Domain, DTO, Utility, Interface, Abstract, Exception
  2. Class name — or enough context to derive a meaningful name
  3. SObject(s) involved — if applicable
  4. Business requirements — plain-language description of what the class should do
  5. Optional preferences:

- Sharing model (with sharing, without sharing, inherited sharing) - Access modifier (public or global) - API version (default: 62.0) - Whether to include ApexDoc comments (default: yes)

If the user provides a clear, complete request, generate immediately without unnecessary back-and-forth.


Code Standards — ALWAYS Follow These

Separation of Concerns

  • Service classes contain business logic. They call Selectors for data and may call Domain classes for SObject-specific behavior.
  • Selector classes encapsulate all SOQL queries. Services never contain inline SOQL.
  • Domain classes encapsulate SObject-specific logic (field defaults, validation, transformation).
  • Keep classes focused on a single responsibility.

Bulkification

  • All methods must operate on collections (List, Set, Map) by default.
  • Never accept a single SObject when a List<SObject> is appropriate.
  • Provide convenience overloads for single-record callers only when it makes the API cleaner, and have them delegate to the bulk method.

Governor Limit Safety

  • No SOQL or DML inside loops. Ever.
  • Collect IDs/records first, query/DML once outside the loop.
  • Use Limits class checks in batch/bulk operations where appropriate.
  • Prefer Database.insert(records, false) with error handling in batch contexts.

Sharing Model

  • Default to with sharing unless the user specifies otherwise.
  • If without sharing or inherited sharing is used, add an ApexDoc @description comment explaining WHY.

Naming Conventions

Class TypePatternExample
Service{SObject}ServiceAccountService
Selector{SObject}SelectorAccountSelector
Domain{SObject}DomainOpportunityDomain
Batch{Descriptive}BatchAccountDeduplicationBatch
Queueable{Descriptive}QueueableExternalSyncQueueable
Schedulable{Descriptive}SchedulableDailyCleanupSchedulable
DTO{Descriptive}DTOAccountMergeRequestDTO
Wrapper{Descriptive}WrapperOpportunityLineWrapper
Utility{Descriptive}UtilStringUtil, DateUtil
InterfaceI{Descriptive}INotificationService
AbstractAbstract{Descriptive}AbstractIntegrationService
Exception{Descriptive}ExceptionAccountServiceException

ApexDoc Comments

Include ApexDoc on every public and global method and on the class itself:

/**
 * @description Brief description of what the class does
 * @author Generated by Apex Class Writer Skill
 */
/**
 * @description Brief description of what the method does
 * @param paramName Description of the parameter
 * @return Description of the return value
 * @example
 * List<Account> results = AccountService.deduplicateAccounts(accountIds);
 */

Null Safety

  • Use guard clauses at the top of methods for null/empty inputs.
  • Use safe navigation (?.) where appropriate.
  • Return empty collections rather than null.

Constants

  • No magic strings or numbers in logic.
  • Use private static final constants or a dedicated constants class.
  • Use Label. custom labels for user-facing strings when appropriate.

Custom Exceptions

  • Each service class should define or reference a corresponding custom exception.
  • Inner exception classes are preferred for simple cases: public class AccountServiceException extends Exception {}
  • Include meaningful error messages with context.

Error Handling

  • Catch specific exceptions, not generic Exception unless re-throwing.
  • Log errors meaningfully (assume a logging utility exists or stub one).
  • In batch contexts, use Database.SaveResult / Database.UpsertResult with partial success.

Output Format

For every class, produce TWO files:

  1. {ClassName}.cls — The Apex class source code
  2. {ClassName}.cls-meta.xml — The metadata file

Meta XML Template

<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>{API_VERSION}</apiVersion>
    <status>Active</status>
</ApexClass>

Default apiVersion is 62.0 unless the user specifies otherwise.


Class Type–Specific Instructions

Service Classes

  • Read and follow: templates/service.cls
  • Stateless — no instance variables holding mutable state
  • All public methods should be static unless there's a compelling reason for instance methods
  • Delegate queries to a Selector class
  • Wrap business logic errors in a custom exception

Selector Classes

  • Read and follow: templates/selector.cls
  • One Selector per SObject (or per logical query domain)
  • Return List<SObject> or Map<Id, SObject>
  • Accept filter criteria as method parameters, not hardcoded
  • Include a private method that returns the base field list to keep DRY

Domain Classes

  • Read and follow: templates/domain.cls
  • Encapsulate field-level defaults, derivations, and validations
  • Operate on List<SObject> — designed to be called from triggers or services
  • No SOQL or DML — only in-memory SObject manipulation

Batch Classes

  • Read and follow: templates/batch.cls
  • Implement Database.Batchable<SObject> and optionally Database.Stateful
  • Use Database.QueryLocator in start() for large datasets
  • Handle partial failures in execute() using Database.SaveResult
  • Implement meaningful finish() — at minimum, log completion

Queueable Classes

  • Read and follow: templates/queueable.cls
  • Implement Queueable and optionally Database.AllowsCallouts
  • Accept data through the constructor — queueables are stateful
  • For chaining, include guard logic to prevent infinite chains
  • Optionally implement Finalizer for error recovery

Schedulable Classes

  • Read and follow: templates/schedulable.cls
  • Implement Schedulable
  • Keep execute() lightweight — delegate to a Batch or Queueable
  • Include a static method that returns a CRON expression for convenience
  • Document the expected schedule in ApexDoc

DTO / Wrapper Classes

  • Read and follow: templates/dto.cls
  • Use public properties — no getters/setters unless validation is needed
  • Include a no-arg constructor and optionally a parameterized constructor
  • Implement Comparable if sorting is needed
  • Keep them serialization-friendly (no transient state unless intentional)

Utility Classes

  • Read and follow: templates/utility.cls
  • All methods public static
  • Class should be public with sharing with a private constructor to prevent instantiation
  • Group related utilities (e.g., StringUtil, DateUtil, CollectionUtil)
  • Every method must be side-effect-free (no DML, no SOQL)

Interfaces

  • Read and follow: templates/interface.cls
  • Define the contract clearly with ApexDoc on every method signature
  • Use meaningful names that describe the capability: INotificationService, IRetryable

Abstract Classes

  • Read and follow: templates/abstract.cls
  • Provide default implementations for common behavior
  • Mark extension points as protected virtual or protected abstract
  • Include a concrete example in the ApexDoc showing how to extend

Custom Exceptions

  • Read and follow: templates/exception.cls
  • Extend Exception
  • Keep them simple — Apex exceptions don't support custom constructors well
  • Name them descriptively: AccountServiceException, IntegrationTimeoutException

Generation Workflow

  1. Determine the class type from the user's request
  2. Read the corresponding template from templates/
  3. Read relevant examples from examples/ if the class type has one
  4. Apply the user's requirements to the template pattern
  5. Generate the .cls file with full ApexDoc
  6. Generate the .cls-meta.xml file
  7. Present both files to the user
  8. Include a brief note on design decisions if any non-obvious choices were made

Anti-Patterns to Avoid

  • ❌ SOQL or DML inside loops
  • ❌ Hardcoded IDs or record type names (use Schema.SObjectType or Custom Metadata)
  • ❌ God classes that mix query + logic + DML
  • public fields on service classes
  • ❌ Returning null from methods that should return collections
  • ❌ Generic catch (Exception e) without re-throwing or meaningful handling
  • ❌ Business logic in Batch start() methods
  • ❌ Tight coupling between classes — use interfaces for extensibility
  • ❌ Magic strings or numbers
  • ❌ Methods longer than ~40 lines — break them into private helpers

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

31.97%
按下载量换算36

Claude

30.4%
按下载量换算35

Cursor

18.97%
按下载量换算22

Gemini CLI

9.49%
按下载量换算11

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

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

来源信息

继续浏览同类 Skills