Golem add config ts

From golemcloud/golem · View interactive version

Golem add config ts is an AI agent skill from the GitHub repository golemcloud/golem. Adding typed configuration to a TypeScript Golem agent. Use when the user asks to add config, settings, or parameters to a TypeScript agent that can be set via golem.yaml or CLI.

How to use this skill

Skill file

Adding Typed Configuration to a TypeScript Agent

Overview

TypeScript agents declare typed configuration with the config option on defineAgent(...). It is a single record of named fields, each a Standard Schema value (Zod / Valibot / ArkType / Effect Schema). At runtime the config is read through this.config inside a handler — one property per declared field, freshly read on each access, and fully typed from the schema.

Steps

  1. Declare a config record on defineAgent(...) — one schema per field
  2. Read config via this.config.<field> in handlers (each access reads the live value)
  3. Set config in golem.yaml or via CLI

Example

Agent with Config

import { z } from 'zod';
import { defineAgent, method } from '@golemcloud/golem-ts-sdk';

export const MyAgent = defineAgent({
    name: 'MyAgent',
    id: { name: z.string() },
    // One config record; nested objects are supported and recursed field-by-field.
    config: {
        foo: z.number(),
        bar: z.string(),
        nested: z.object({
            a: z.boolean(),
            b: z.array(z.number()),
        }),
    },
    methods: {
        getFoo: method({ input: {}, returns: z.number() }),
        describe: method({ input: {}, returns: z.string() }),
    },
});

export const MyAgentImpl = MyAgent.implement({
    init: () => ({}),
    methods: {
        getFoo() {
            // `this.config` is statically typed from the config record — no casts,
            // and `this.config.<typo>` is a compile error.
            return this.config.foo;
        },
        describe() {
            const n = this.config.nested;
            return `${this.config.bar}:${n.a}:${n.b.join(',')}`;
        },
    },
});

this.config is also available during init via the InitContext argument (init: (ctx) => ({ ... ctx.config.foo ... })).

Setting Config in `golem.yaml`

agents:
  MyAgent:
    config:
      foo: 42
      bar: "hello"
      nested:
        a: true
        b: [1, 2, 3]

Setting Config via CLI

golem agent create --keyed 'MyAgent("agent-1")' \
  --config foo=42 \
  --config bar=hello \
  --config nested.a=true

Config Cascade

Config values are resolved in order of increasing precedence:

componentTemplates → components → agents, with presets resolved within each template,

component, and agent layer, not as one final global layer.

Values set closer to the agent override those set at broader scopes.

Key Constraints

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.