Golem scala code generation

From golemcloud/golem · View interactive version

Golem scala code generation is an AI agent skill from the GitHub repository golemcloud/golem. Develops shared Scala source generation for the Golem sbt and Mill plugins. Use when changing source discovery, validated codegen IR, generated RPC/tool clients, auto-registration, or plugin generation hooks under sdks/scala.

How to use this skill

Skill file

Golem Scala Code Generation

Keep semantic generation in sdks/scala/codegen/ and the sbt/Mill integrations thin.

Follow the surrounding pipeline

The current shared flow is:

Scala source -> SourceDiscovery -> validation / semantic IR -> source renderer
             -> GeneratedFile + warnings -> sbt or Mill writes/formats files

CodegenPipeline rejects discovery and projection errors before emitting files. AgentSurfaceIR is the agent interchange model; ToolProjectionIR resolves and validates tool command shapes shared by ordinary tool and middleware renderers. Preserve this separation when adding behavior: do not independently rediscover semantics in each renderer or build plugin.

There is no repository-wide rule that generation must be AST-only. Follow the implementation being changed:

Prefer typed, validated IR and small shared rendering helpers over either brittle ad-hoc templates or an unnecessary AST rewrite.

Shared-library constraints

The same codegen/src/main/scala sources are consumed by:

Therefore avoid Scala-3-only source syntax in shared code. The current Mill consumer fixtures

compile generated application code with Scala 3.3.7; this fixture setting is not the codegen

host version and should not be generalized to every Scala.js project.

Keep shared APIs deterministic and free of sbt/Mill types and file I/O. Return relative paths, contents, diagnostics, and errors. Build-tool wrappers own source collection, logging, managed output directories, formatting, caching, and task wiring.

Integration points

Both plugins must remain behaviorally aligned. Check their existing task names and output handling before adding a hook rather than copying an old example.

Current generated RPC surface

Generation is mode-aware:

Treat RpcCodegen.scala, AgentClientRuntime.scala, and InvocationMetadata.scala as authoritative for exact signatures.

Verification

Start with the affected generator tests and compile a consumer when output contracts change:

cd sdks/scala
sbt "++3.8.2; codegen/test"
sbt "++2.12.21!; codegen/test; sbtPlugin/test"
sbt "++3.8.2; testAgents/fastLinkJS"

For Mill integration changes, use the tasks documented in sdks/scala/mill/README.md and the fixtures in mill/build.mill. Run project-scoped scalafmtCheckAll where possible. Integration tests are required only when behavior reaches generated applications or the host runtime.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.