Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

builtin-developer

БесплатноЗапускает вложенные скриптыНе проверен

Guides development of AILANG builtin functions. Use when user wants to add a builtin function, register new builtins, or understand the builtin system…

sunholo-dataот sunholo-data★ 39 звёзд на GitHub

Об этом скилле

Builtin Developer

Add new builtin functions to AILANG using the modern registry system (M-DX1).

Quick Start

Development time: ~2.5 hours (down from 7.5h with legacy system)

Most common workflow:

  1. Register builtin with metadata (~30 min)
  2. Write hermetic tests (~1 hour)
  3. Validate and inspect (~30 min)
  4. Runtime auto-wires (already done!)

When to Use This Skill

Invoke this skill when:

  • User wants to add a new builtin function
  • User asks about builtin registration process
  • User needs to understand the builtin system
  • User wants to validate or inspect builtins
  • User asks "how do I add a builtin?"

System Overview

Status: 🎉 M-DX1 COMPLETE (Oct 2025) - 52 builtins migrated, fully documented

Key Benefits:

  • 67% faster: 2.5h instead of 7.5h
  • 1 file instead of 4: Single-point registration
  • 71% less code: Type Builder DSL reduces boilerplate
  • Automatic wiring: Registry connects to runtime/link
  • Hermetic tests: MockEffContext with HTTP/FS mocking

Components:

  • Central Registry (internal/builtins/spec.go) - Single registration point
  • Type Builder DSL (internal/types/builder.go) - Fluent type construction
  • Test Harness (internal/effects/testctx/) - Hermetic testing helpers
  • CLI Commands - Validation and inspection tools

Available Scripts

scripts/validate_builtins.sh

Validate all builtins in the registry.

Usage:

.claude/skills/builtin-developer/scripts/validate_builtins.sh

What it checks:

  • All builtins are registered
  • Proper metadata structure
  • Type signatures valid
  • Test coverage exists

scripts/check_builtin_health.sh

Run ailang doctor and list commands.

Usage:

.claude/skills/builtin-developer/scripts/check_builtin_health.sh

Workflow

Step 1: Register the Builtin (~30 min)

Create or edit module file (e.g., internal/builtins/string.go):

// internal/builtins/string.go
func init() {
    registerMyBuiltin()
}

func registerMyBuiltin() {
    RegisterEffectBuiltin(BuiltinSpec{
        Module:  "std/string",
        Name:    "_str_reverse",
        NumArgs: 1,
        IsPure:  true,        // or false with Effect: "IO"
        Type:    makeReverseType,
        Impl:    strReverseImpl,
        Metadata: &BuiltinMetadata{
            Description: "Reverse a string (Unicode-aware)",
            Params: []ParamDoc{
                {Name: "s", Description: "String to reverse"},
            },
            Returns: "Reversed string",
            Examples: []Example{
                {Code: `_str_reverse("hello")`, Description: "Returns \"olleh\""},
            },
            Since:     "v0.3.15",
            Stability: StabilityStable,
            Tags:      []string{"string", "reverse", "unicode"},
            Category:  "string",
        },
    })
}

func makeReverseType() types.Type {
    T := types.NewBuilder()
    return T.Func(T.String()).Returns(T.String())
}

func strReverseImpl(ctx *effects.EffContext, args []eval.Value) (eval.Value, error) {
    str := args[0].(*eval.StringValue).Value
    runes := []rune(str)
    for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
        runes[i], runes[j] = runes[j], runes[i]
    }
    return &eval.StringValue{Value: string(runes)}, nil
}

Key points:

  • Use RegisterEffectBuiltin() in init()
  • Use Type Builder DSL for type construction
  • Include complete metadata (description, params, examples, tags)
  • Set IsPure: true for pure functions, or Effect: "IO" for effects

See: resources/type_builder_examples.md for type patterns

Step 2: Write Hermetic Tests (~1 hour)

Add tests in internal/builtins/register_test.go:

func TestStrReverse(t *testing.T) {
    ctx := testctx.NewMockEffContext()

    tests := []struct {
        input    string
        expected string
    }{
        {"hello", "olleh"},
        {"", ""},
        {"🎉", "🎉"},
    }

    for _, tt := range tests {
        result, err := strReverseImpl(ctx, []eval.Value{
            testctx.MakeString(tt.input),
        })
        assert.NoError(t, err)
        assert.Equal(t, tt.expected, testctx.GetString(result))
    }
}

Test Harness helpers:

  • testctx.NewMockEffContext() - Create test context
  • testctx.MakeString(), MakeInt(), MakeRecord() - Create test values
  • testctx.GetString(), GetInt(), GetRecord() - Extract values

For HTTP/FS effects:

ctx := testctx.NewMockEffContext()
ctx.GrantAll("Net")  // Grant Net capability
ctx.SetHTTPClient(server.Client())  // Use test server

See: resources/testing_patterns.md for more examples

Step 3: Validate and Inspect (~30 min)

Run validation:

# Validate all builtins
ailang doctor builtins

# List all builtins by module
ailang builtins list --by-module

# Check for orphaned builtins (migration safety)
ailang builtins check-migration

**Run

Полный SKILL.md на GitHub

Установить builtin-developer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

resources/reference.mdresources/testing_patterns.mdresources/type_builder_examples.mdscripts/check_builtin_health.shscripts/example_script.shscripts/validate_builtins.sh

FAQ

Что делает скилл builtin-developer?

Guides development of AILANG builtin functions. Use when user wants to add a builtin function, register new builtins, or understand the builtin system. Reduces development time from 7.5h to 2.5h (-67%).

Как установить скилл builtin-developer?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл builtin-developer запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить builtin-developer с