npx skills add https://github.com/jaganpro/sf-skills --skill sf-apex当用户需要生产级 Apex 时使用此技能:包括新类、触发器、选择器、服务、异步作业、可调用方法、测试类,或对现有 .cls / .trigger 代码进行基于证据的审查。
当工作涉及以下内容时,使用 sf-apex:
@InvocableMethod、Queueable、Batch、Schedulable 或测试类相关工作当用户进行以下操作时,请委托给其他技能:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
询问或推断:
在编写代码前,检查项目结构:
检查:
| 需求 | 首选模式 |
|---|---|
| 简单的可重用逻辑 | 服务类 |
| 查询密集型的数据访问 | 选择器 |
| 单一对象的触发器行为 | 一个触发器 + 处理程序 / TAF 操作 |
| Flow 需要复杂逻辑 | @InvocableMethod |
| 后台处理 | 默认使用 Queueable |
| 非常大的数据集 | Batch Apex 或 Database.Cursor 模式 |
| 可重复的验证 | 专用的测试类 + 测试数据工厂 |
生成的代码应满足:
在交付前,根据 150 分评分标准进行评估。
当需要进行组织验证时,交付给:
未经明确停止并解释问题,切勿生成以下内容:
| 反模式 | 阻碍原因 |
|---|---|
| 循环内的 SOQL | 导致治理限制失败 |
| 循环内的 DML | 导致治理限制失败 |
| 缺少共享模型 | 存在安全 / 数据暴露风险 |
| 硬编码的 ID | 导致部署和可移植性失败 |
空的 catch 块 | 导致静默失败 / 可观测性差 |
| 使用用户输入构建字符串的 SOQL | 存在注入风险 |
| 没有断言的测试 | 导致测试套件出现假阳性 |
默认修复方向:
with sharingWITH USER_MODE| 场景 | 默认选择 |
|---|---|
| 标准的异步工作 | Queueable |
| 非常大的记录处理 | Batch Apex |
| 重复性计划任务 | Scheduled Flow 或 Schedulable |
| 任务后清理 | Finalizer |
| 长时间运行的 Lightning 调用 | Continuation |
对每个功能使用 PNB 模式:
在可用时优先使用当前惯用法:
obj?.Field__cvalue ?? fallbackAssert.* 而非旧式断言风格WITH USER_MODE 和显式的安全处理完成时,按此顺序报告:
建议格式:
Apex 工作: <摘要>
文件: <路径>
设计: <模式 / 框架选择>
风险: <安全性、批量处理、异步、依赖项说明>
测试: <需要运行 / 添加的内容>
部署: <试运行或下一步>
此技能支持对 .cls 和 .trigger 文件进行 LSP 辅助的编写循环:
| 需求 | 委托给 | 原因 |
|---|---|---|
| 首先描述对象 / 字段 | sf-metadata | 避免针对错误的架构进行编码 |
| 生成批量或边缘情况数据 | sf-data | 创建真实的测试数据集 |
| 运行 Apex 测试 / 修复失败的测试 | sf-testing | 执行并迭代失败 |
| 部署到组织 | sf-deploy | 验证和部署编排 |
| 构建调用 Apex 的 Flow | sf-flow | 声明式编排 |
| 构建调用 Apex 的 LWC | sf-lwc | UI/控制器集成 |
| 分数 | 含义 |
|---|---|
| 120+ | 强大的生产就绪 Apex |
| 90–119 | 良好的实现,部署前需审查 |
| 67–89 | 可接受但需要改进 |
| < 67 | 阻止部署 |
每周安装量
318
代码库
GitHub 星标数
223
首次出现
Jan 22, 2026
安全审计
安装于
codex302
gemini-cli300
opencode299
cursor298
github-copilot297
amp291
Use this skill when the user needs production Apex : new classes, triggers, selectors, services, async jobs, invocable methods, test classes, or evidence-based review of existing .cls / .trigger code.
Use sf-apex when the work involves:
@InvocableMethod, Queueable, Batch, Schedulable, or test-class workDelegate elsewhere when the user is:
Ask for or infer:
Before authoring, inspect the project shape:
Check for:
| Need | Preferred pattern |
|---|---|
| simple reusable logic | service class |
| query-heavy data access | selector |
| single object trigger behavior | one trigger + handler / TAF action |
| Flow needs complex logic | @InvocableMethod |
| background processing | Queueable by default |
| very large datasets | Batch Apex or Database.Cursor patterns |
| repeatable verification | dedicated test class + test data factory |
Generate code that is:
Evaluate against the 150-point rubric before handoff.
When org validation is needed, hand off to:
Never generate these without explicitly stopping and explaining the problem:
| Anti-pattern | Why it blocks |
|---|---|
| SOQL in loops | governor-limit failure |
| DML in loops | governor-limit failure |
| missing sharing model | security / data exposure risk |
| hardcoded IDs | deployment and portability failure |
empty catch blocks | silent failure / poor observability |
| string-built SOQL with user input | injection risk |
| tests without assertions | false-positive test suite |
Default fix direction:
with sharing unless justified otherwiseWITH USER_MODE where appropriateSee references/anti-patterns.md and references/security-guide.md.
| Scenario | Default |
|---|---|
| standard async work | Queueable |
| very large record processing | Batch Apex |
| recurring schedule | Scheduled Flow or Schedulable |
| post-job cleanup | Finalizer |
| long-running Lightning callouts | Continuation |
Use the PNB pattern for every feature:
Prefer current idioms when available:
obj?.Field__cvalue ?? fallbackAssert.* over legacy assertion styleWITH USER_MODE and explicit security handling where relevantWhen finishing, report in this order:
Suggested shape:
Apex work: <summary>
Files: <paths>
Design: <pattern / framework choices>
Risks: <security, bulkification, async, dependency notes>
Tests: <what to run / add>
Deploy: <dry-run or next step>
This skill supports an LSP-assisted authoring loop for .cls and .trigger files:
Full guide: references/troubleshooting.md
| Need | Delegate to | Reason |
|---|---|---|
| describe objects / fields first | sf-metadata | avoid coding against wrong schema |
| seed bulk or edge-case data | sf-data | create realistic test datasets |
| run Apex tests / fix failing tests | sf-testing | execute and iterate on failures |
| deploy to org | sf-deploy | validation and deployment orchestration |
| build Flow that calls Apex | sf-flow | declarative orchestration |
| build LWC that calls Apex | sf-lwc |
| Score | Meaning |
|---|---|
| 120+ | strong production-ready Apex |
| 90–119 | good implementation, review before deploy |
| 67–89 | acceptable but needs improvement |
| < 67 | block deployment |
Weekly Installs
318
Repository
GitHub Stars
223
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex302
gemini-cli300
opencode299
cursor298
github-copilot297
amp291
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
138,300 周安装
gh-issues:基于AI子代理自动修复GitHub Issues的开源自动化工具
308 周安装
Botchan:Base区块链智能体消息层,实现无需许可的链上通信
308 周安装
Worktrunk CLI 工具:高效管理 Git Worktree,自动化开发工作流
308 周安装
viem 集成指南:为 TypeScript/JavaScript 应用连接 EVM 区块链
308 周安装
Appwrite TypeScript SDK 使用指南 - 客户端与服务器端开发教程
309 周安装
React Native 棕地迁移指南:逐步集成到原生应用(Expo/裸RN)
309 周安装
| UI/controller integration |