AgentSkillsCN

codegen-sync

验证 TypeScript 代码生成是否与 Elixir 协议定义保持同步。在 core/ 目录中修改 Elixir 结构体、协议消息或 RPC 类型后,使用此技能重新生成并验证 TypeScript 客户端 SDK 类型。

SKILL.md
--- frontmatter
name: codegen-sync
description: Verifies TypeScript codegen is in sync with Elixir protocol definitions. Use this skill after modifying Elixir structs, protocol messages, or RPC types in core/ to regenerate and verify the TypeScript client SDK types.
globs: "{core/lib/opal/rpc/**,core/lib/opal/agent/**,cli/src/sdk/**}"

Codegen Sync Skill

This project uses code generation to keep TypeScript SDK types in sync with Elixir protocol definitions. When Elixir types change, the TypeScript side must be regenerated.

When to act

  • After modifying any Elixir structs, message types, or RPC definitions in core/.
  • After adding or changing tool schemas in core/lib/opal/tool/.
  • When CI fails with a codegen drift error.
  • When the user asks to sync or regenerate types.

Commands

bash
# Run codegen (Elixir -> TypeScript)
pnpm codegen

# Verify codegen is up to date (what CI runs)
pnpm nx run cli:codegen:check

Workflow

  1. After modifying Elixir protocol types, run pnpm codegen.
  2. Review the generated diff in cli/src/sdk/ to verify correctness.
  3. Include the regenerated files in the same commit as the Elixir changes.

Rules

  1. Never hand-edit generated files. Always regenerate from the Elixir source.
  2. If codegen output looks wrong, fix the Elixir definitions or the codegen script (scripts/codegen_ts.exs), not the output.
  3. Always commit codegen output alongside the source changes — never in a separate commit.