Token导航 LogoToken导航

Agent Skill · 开发规范

boxlang-best-practices(博克斯朗最佳实践)

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

boxlang-best-practices 是开发规范类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描已通过,按安装量在开发规范类的 1,265 个 Skill 里排第 1,135。

总安装 220周安装 9GitHub Stars 公开资料未说明下载 71核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:boxlang-best-practices(博克斯朗最佳实践)
来源仓库:https://github.com/ortus-boxlang/skills
仓库路径:skills/boxlang-best-practices
安装命令:
npx skills add https://github.com/ortus-boxlang/skills --skill boxlang-best-practices
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/ortus-boxlang/skills --skill boxlang-best-practices

这个 Skill 是做什么的

开发规范类 Skill 用来统一代码风格、目录结构和评审口径,产出多为检查清单或改写建议。

BoxLang Best Practices 提供博克斯朗语言的编码规范和最佳实践指南。适用于编写可读、可维护且高性能的 BoxLang 代码的开发者。涵盖命名约定、文件结构、常量定义和类组织等核心开发规范。安装后可直接参考技能文档中的示例进行代码风格统一。建议结合代码审查流程确保团队遵循一致的编码标准。

来源仓库内路径:skills/boxlang-best-practices

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/ortus-boxlang/skills --skill boxlang-best-prac…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

boxlang-best-practices 怎么安装?

在终端执行 npx skills add https://github.com/ortus-boxlang/skills --skill boxlang-best-practices。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

boxlang-best-practices 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

boxlang-best-practices 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

boxlang-best-practices 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

boxlang-best-practices 用的人多吗?

公开数据是累计安装 220 次,近一周安装 9 次,下载 71 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

boxlang-best-practices 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发规范类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发规范类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
vercel-react-best-practices

Vercel React 最佳实践 · Codex、Claude

8,490,72025,918操作浏览器MIT通过
web-design-guidelines

网页设计指南 · Codex、Claude

6,686,01625,885需要联网MIT有提醒
remotion-best-practices

Remotion 最佳实践 · Codex、Claude

6,505,6323,027操作浏览器MIT有提醒
supabase-postgres-best-practices

Supabase Postgres 最佳实践 · Codex、Claude

3,175,5232,030需要联网MIT通过
next-best-practices

Next.js 最佳实践 · Codex、Claude

1,848,240841操作浏览器MIT通过
boxlang-best-practices

博克斯朗最佳实践 · 本页

220—接触敏感数据未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

BoxLang Best Practices

Overview

BoxLang is a modern dynamic JVM language. These best practices reflect idiomatic BoxLang patterns informed by the language's design, CFML heritage, and JVM performance characteristics. Following them produces code that is readable, maintainable, performant, and safe.


Naming Conventions

ItemConventionExample
VariablescamelCaseuserProfile, orderTotal
Functions/MethodscamelCasegetUserById(), processOrder()
ClassesPascalCaseUserService, OrderProcessor
ConstantsUPPER_SNAKE_CASEMAX_RETRIES, DEFAULT_TIMEOUT
Files (classes)PascalCaseUserService.bx
Files (templates)camelCase or kebab-caseuserProfile.bxm, order-details.bxm
Files (scripts)camelCasebuildReport.bxs
// Good
class UserService {
    function getUserById( required numeric id ) {
        var MAX_RETRIES = 3
        var userId = arguments.id
        return userRepository.find( userId )
    }
}

Variable Scoping

Always declare local variables with var inside functions to avoid polluting the variables scope (the component-level scope).

// BAD — leaks into variables scope
function process() {
    result = doWork()
    return result
}

// GOOD — properly local
function process() {
    var result = doWork()
    return result
}

Use explicit scope prefixes when ambiguity exists:

function getUser( required numeric id ) {
    // Explicitly scope to avoid confusion
    var userData = variables.userRepo.find( arguments.id )
    return userData
}

Scope Lookup Performance

BoxLang walks the scope chain on each unscoped variable access. In hot code paths (tight loops, high-traffic request handlers), scope your variables explicitly for predictable performance:

// GOOD in hot paths — no scope chain walk
var len = arguments.items.len()
for ( var i = 1; i <= len; i++ ) {
    // process arguments.items[ i ]
}

Functions

Always Declare Argument Types and Required Status

// BAD — no type information
function processOrder( order, userId ) { ... }

// GOOD — self-documenting, validated at runtime
function processOrder( required struct order, required numeric userId ) {
    ...
}

Use Named Arguments for Clarity

// Hard to read
createUser( "John", "Doe", "john@example.com", true )

// GOOD — named arguments document intent
createUser(
    firstName = "John",
    lastName  = "Doe",
    email     = "john@example.com",
    active    = true
)

Return Types

Declare return types for public functions to document contracts and enable better IDE support:

struct function getUser( required numeric id ) {
    return userService.find( arguments.id )
}

array function listActiveUsers() {
    return userService.findByStatus( "active" )
}

Error Handling

Catch Specific Exception Types

// BAD — catches everything, hides bugs
try {
    processOrder( order )
} catch ( any e ) {
    logError( e )
}

// GOOD — handle specific cases, re-throw unknown
try {
    processOrder( order )
} catch ( "Database" e ) {
    handleDatabaseError( e )
} catch ( "Validation" e ) {
    return { success: false, message: e.message }
} catch ( any e ) {
    // Re-throw unexpected errors
    rethrow
}

Use cffinally for Cleanup

transaction {
    try {
        updateOrder( order )
        chargePayment( payment )
        transactionCommit()
    } catch ( any e ) {
        transactionRollback()
        rethrow
    }
}

Null Safety

Use the safe-navigation operator (?.) and Elvis operator (?:) to avoid null pointer errors:

// Null-safe chained access
var city = user?.address?.city ?: "Unknown"

// Null-safe method calls
var count = order?.items?.len() ?: 0

Prefer isNull() over direct comparisons with null:

if ( isNull( result ) ) {
    return getDefault()
}

Closures vs Lambdas

Use lambdas (->) for pure deterministic operations on their arguments only. Use closures (=>) when accessing outer scope variables or calling external functions/BIFs.

// Lambda — only uses the item argument (pure transform)
var doubled = numbers.map( ( n ) -> n * 2 )

// Closure — accesses outer variable `threshold`
var filtered = numbers.filter( ( n ) => n > threshold )

// Closure — calls external BIF
var upper = words.map( ( w ) => uCase( w ) )

Struct and Array Literals

Prefer literal syntax over constructor functions:

// GOOD — literal syntax
var user = {
    name:  "Alice",
    email: "alice@example.com",
    roles: [ "admin", "user" ]
}

// Avoid unless dynamic keys are needed
var user = structNew()
user.name = "Alice"

Use ordered struct literal syntax when key order matters:

// Ordered struct (insertion order preserved)
var config = [=
    host: "localhost",
    port: 5432,
    database: "myapp"
=]

String Interpolation

Use #expression# for interpolation in strings and templates. For complex expressions, assign to a variable first for readability:

// Simple interpolation
var message = "Hello, #user.name#!"

// Complex — extract first
var formattedDate = dateTimeFormat( now(), "long" )
var header = "Report generated on #formattedDate#"

Component (Class) Design

Constructor Pattern

Use init() as the constructor. Return this for fluent construction:

class UserService {

    property name="userRepo" inject="UserRepository"

    function init( required UserRepository userRepository ) {
        variables.userRepo = arguments.userRepository
        return this
    }

}

Keep Classes Focused (Single Responsibility)

Each .bx class should have one primary purpose. Avoid "god objects" that handle unrelated concerns. Split into service, repository, and model layers.


Performance Tips

  1. Cache expensive lookups — store results in application scope for shared read-only data; invalidate on change.
  2. Use trustedCache=true in production — prevents disk I/O on class file checks.
  3. Pre-compute in constructors — if a value won't change, compute it once during instantiation.
  4. Prefer each() / map() / filter() over manual loops for collection work — more readable and JIT-friendly.
  5. Use virtual threads (runAsync defaults) for I/O-bound async work; use fixed-pool executors for CPU-bound work.

Code Organization

/app
  /models           -- Business domain classes (.bx)
  /services         -- Service layer classes (.bx)
  /repositories     -- Data access classes (.bx)
  /handlers         -- Request handlers / controllers (.bx)
  /views            -- Templates (.bxm)
  /includes         -- Reusable partial templates (.bxm)
  /scripts          -- Standalone scripts (.bxs)
  Application.bx    -- Application lifecycle

Common Anti-Patterns to Avoid

Anti-PatternProblemFix
Unscoped vars in functionsVariables bleed into component scopeAlways use var
Silent catch-all catch(any)Swallows unexpected errorsRe-throw unknown exceptions
Logic in templatesHard to test, poor separationMove to services/handlers
Direct SQL in handlersNo reuse, SQL injection riskUse repository classes with parameterized queries
Storing secrets in codeSecurity riskUse environment variables via ${env.VAR_NAME} in config
Overusing application scopeConcurrency bugsUse proper locking (bx:lock) for writes
arr[0] (zero-based index)ArrayIndexOutOfBoundsExceptionBoxLang arrays are 1-indexed: use arr[1] or arr.first()
Trailing ; on statementsNoisy / inconsistent styleSemicolons are optional on statements — omit them
cfheader() / <cfabort>CFML syntax, not BoxLangUse bx:header, bx:abort, etc.
Named args on Java objectsNot supported, throws runtime errorAlways use positional arguments for Java method calls
createObject("java","path") per callVerbose, repeated boilerplateimport java:fully.qualified.Class once, then use the class name directly

BoxLang vs CFML Quick-Reference

BoxLang evolved from CFML but uses different syntax for many constructs. Do NOT use cf-prefixed tags or functions in BoxLang source files.

CFMLBoxLang Equivalent
cfheader(name="X", value="Y")bx:header name="X" value="Y";
cflocation(url="...")bx:location url="...";
cfabortbx:abort;
cfparam name="x" default=""bx:param name="x" default="";
cfinclude template="f.cfm"bx:include template="f.bxm";
<cfsilent>bx:silent {...}
createObject("java","path.Class")import java:path.Class then new java:path.Class()

Array Best Practices

BoxLang arrays are 1-indexed. This is a common source of bugs for developers coming from Java/JavaScript backgrounds.

var items = [ "a", "b", "c" ]

// CORRECT
var first = items[ 1 ]          // "a"
var last  = items[ items.len() ] // "c"
var first = items.first()        // preferred — more readable
var last  = items.last()         // preferred

// WRONG (throws ArrayIndexOutOfBoundsException)
var first = items[ 0 ]

// Looping — i starts at 1
for ( var i = 1; i <= items.len(); i++ ) {
    process( items[ i ] )
}

Passing Single Values to Java Varargs

Java varargs methods require a BoxLang array, not a bare scalar value:

// CORRECT — wrap in array
storage.query( "SELECT * FROM t WHERE id = ?", [ requestId ] )

// WRONG — bare value is not accepted by Java varargs
storage.query( "SELECT * FROM t WHERE id = ?", requestId )    // throws

平台分布

Codex

35.36%
按下载量换算25

Claude

30.85%
按下载量换算22

Cursor

17.25%
按下载量换算12

Gemini CLI

8.84%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

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

继续浏览同类 Skills