返回顶部
a

ax-developmentAX开发框架

Agent Experience (AX) development framework. Apply when building libraries, CLIs, APIs, or any software that will be consumed by AI agents — not just humans. Covers: deterministic design, machine-readable contracts, fail-fast validation, composable primitives, documentation co-location. Use when: (1) starting a new project/lib that agents will use, (2) reviewing code for agent-friendliness, (3) designing CLI output contracts, (4) structuring error handling for machine consumption, (5) writing te

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
245
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

ax-development

AX 开发 — 智能体体验框架

软件正越来越多地被AI智能体而非人类所消费。AX(智能体体验)是一门设计代码、API和接口的学科,使智能体能够可靠且自主地运行。

八大原则

1. 快速早失败

在昂贵操作之前拒绝无效输入。在边界处验证,而非调用栈深处。

typescript
// ✅ 在构建复合体之前验证同步规则
const errors = validateSyncRules(rules, knownSources);
if (errors.length > 0) throw new AXError(INVALIDSYNCRULES, errors);

// ❌ 在HTML渲染过程中才发现无效规则

2. 确定性输出

相同输入 → 相同输出。无时钟依赖,确定性路径中无随机ID,无隐藏状态变更。

typescript
// ✅ 纯函数,可预测
function buildDescriptor(resources, orchestration) { ... }

// ❌ 结果静默依赖于 Date.now() 或 Math.random()

当非确定性不可避免时(UUID、时间戳),将其隔离并使其可注入。

3. 机器可读的错误

带有代码的结构化错误,而非仅字符串消息。智能体解析错误代码,而非文字描述。

typescript
// ✅ 结构化,可解析
{ code: ORPHANSYNCTARGET, target: viz:render, available: [postgres:query] }

// ❌ 仅一个字符串
throw new Error(Target not found in resources);

4. 显式优于隐式

没有静默改变行为的魔法默认值。每个配置都有可见的默认值。无隐藏启发式规则。

typescript
// ✅ 默认值显式且已文档化
function render(descriptor, { theme = auto } = {}) { ... }

// ❌ 从环境变量静默检测主题

5. 可组合的原语

每个函数只做一件事。流水线步骤独立且可重新组合。智能体可单独使用每个步骤。

Collector → Composer → Renderer // 完整流水线
Collector → custom logic → Renderer // 智能体跳过composer

6. 窄契约

最小必需输入,最大类型安全。只接受所需内容。只返回有用内容。避免上帝对象。

typescript
// ✅ 精确获取所需内容
function resolveSyncRules(rules: UiSyncRule[], sources: string[]): ResolvedSyncRule[]

// ❌ 仅需两个字段却接收整个配置对象
function resolveSyncRules(config: FullAppConfig): ResolvedSyncRule[]

7. 就近文档

文档位于其描述的代码旁边。每个模块有自己的契约。智能体通过浏览文件树而非搜索Wiki来查找文档。

src/sync/
├── mod.ts # 公共导出
├── resolver.ts # 实现
├── resolver_test.ts # 测试即文档
└── contract.md # I/O契约、不变量(可选,用于复杂模块)

8. 测试优先的不变量

每个行为都有测试。测试是可执行的规范,智能体通过阅读测试来理解契约。优先边界测试而非快乐路径。

typescript
// 测试边界,而非仅中间路径
Deno.test(empty resources → empty descriptor, ...);
Deno.test(orphan sync target → validation error, ...);
Deno.test(broadcast rule → resolves to all-except-sender, ...);

应用AX — 决策检查清单

在发布任何模块之前,验证:

  • - [ ] 智能体能否在零环境知识下调用此函数?
  • [ ] 所有错误是否机器可解析(代码 + 结构化数据)?
  • [ ] 使用相同输入运行两次,输出是否会变化?
  • [ ] 是否存在函数签名中不可见的隐式行为?
  • [ ] 能否在不导入无关模块的情况下使用此模块?
  • [ ] 测试是否覆盖无效/边界输入,而非仅快乐路径?
  • [ ] 代码的一级目录内是否有文档?
  • [ ] 智能体是否需要阅读源代码来理解契约,还是类型+测试就足够?

CLI契约(针对CLI工具)

构建智能体将调用的CLI时:

  • - 默认使用机器可读输出(JSON/JSONL),通过--human可选人类可读
  • 输出中包含稳定键名(而非仅美化打印的文本)
  • 一致使用退出码(0=成功,1=用户错误,2=系统错误)
  • 版本化输出格式 — JSON结构的破坏性变更需要标志或迁移路径
  • 为便于智能体发现,优先使用显式标志而非位置参数

详见 references/cli-contracts.md。

错误分类法

AX兼容项目的标准错误码前缀:

前缀领域示例
INVALID输入验证INVALIDSYNCRULES
MISSING
缺少必需数据 | MISSINGRESOURCEURI |
| ORPHAN* | 引用不存在的实体 | ORPHANSYNC_TARGET |
| CONFLICT* | 矛盾配置 | CONFLICTLAYOUT_CHILDREN |
| UNSUPPORTED* | 有效但未实现 | UNSUPPORTEDLAYOUT |

采用此分类法或定义自己的分类法 — 关键在于项目内的一致性。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 ax-development-1776200853 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 ax-development-1776200853 技能

通过命令行安装

skillhub install ax-development-1776200853

下载

⬇ 下载 ax-development v1.0.0(免费)

文件大小: 4.95 KB | 发布时间: 2026-4-15 11:48

v1.0.0 最新 2026-4-15 11:48
Initial release of ax-development — an Agent Experience (AX) framework for building agent-friendly software.

- Defines 8 core AX principles: fail-fast validation, deterministic outputs, structured errors, explicit defaults, composable primitives, minimal contracts, co-located documentation, test-first invariants.
- Provides a practical checklist for making functions, APIs, or CLIs agent-consumable.
- Details CLI contract guidelines for agent interaction, including output format, error codes, and versioning.
- Introduces a standard error taxonomy for structured, machine-readable error handling.
- Includes example patterns and reference file layout for AX-compliant development.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部