Agent skill

Add Function Body

by onnx in onnx/onnx

Add a function body definition to an ONNX operator, defining how it decomposes into simpler ops.

Apache-2.0Auto-check passedAI & LLM Engineering

Install Add Function Body

skills CLI
$ npx skills add onnx/onnx --skill add-function-body -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install onnx/onnx add-function-body --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/onnx/onnx.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/add-function-body .claude/skills/add-function-body && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
add-function-body
GitHub stars
22k
Token cost
~1.1k tokens
SKILL.md length
231 words
Files
1
Skills in repo
4
Repo updated
First seen
Licence
Apache-2.0

At a glance

Add a function body definition to an ONNX operator, defining how it decomposes into simpler ops.

  • Asked to make an op decomposable
  • SKILL.md covers File Locations, Method 1: Simple String-Based…, Method 2: Context-Dependent… and FunctionBuilder API, plus 5 more sections
  • Calls python
  • Add a FunctionBody

What it does

Add Function Body is an agent skill from onnx/onnx. Add a function body definition to an ONNX operator, defining how it decomposes into simpler ops. Use when asked to make an op decomposable, add a FunctionBody, implement SetContextDependentFunctionBodyBuilder, or express an op in terms of other ONNX operators.

Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering Deep learning. It works with ONNX. The repository describes itself as: Open standard for machine learning interoperability. The licence is Apache-2.0.

When your agent uses it

  • Asked to make an op decomposable
  • Add a FunctionBody
  • Implement SetContextDependentFunctionBodyBuilder
  • Express an op in terms of other ONNX operators

Example prompts

  • “/add-function-body”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit ab429ea. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Add Function Body loads about 1.1k tokens when it runs. Until then it costs about 70 tokens; SKILL.md has 231 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~70
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from onnx/onnx at commit ab429ea, republished under its Apache-2.0 licence (© onnx). 231 words, ~1,052 tokens.

Download SKILL.mdSave it as .claude/skills/add-function-body/SKILL.md (or your agent's skills folder).
name
add-function-body
description
Add a function body definition to an ONNX operator, defining how it decomposes into simpler ops. Use when asked to make an op decomposable, add a FunctionBody, implement SetContextDependentFunctionBodyBuilder, or express an op in terms of other ONNX operators.

Follow the full guide in docs/AddFunctionBody.md.

File Locations

ComponentFile
Function body definitiononnx/defs/<domain>/defs.cc (inline with schema)
FunctionBuilder utilitiesonnx/defs/function.h
Function teststests/cpp/function_get_test.cc, tests/cpp/function_verify_test.cc

Method 1: Simple String-Based Function Body

cpp
ONNX_OPERATOR_SET_SCHEMA(
    LessOrEqual, 16,
    OpSchema()
        // ... inputs, outputs, type constraints ...
        .TypeAndShapeInferenceFunction(inferenceFunction)
        .FunctionBody(R"ONNX(
        {
            O1 = Less (A, B)
            O2 = Equal (A, B)
            C = Or (O1, O2)
        }
        )ONNX"));

With explicit opset version:

cpp
        .FunctionBody(R"ONNX(...)ONNX", 18)  // Valid from opset 18

Referencing attributes with @attr_name:

cpp
        .FunctionBody(R"ONNX(
          {
            Alpha = Constant <value_float: float = @alpha>()
            AlphaCast = CastLike (Alpha, X)
            ...
          }
        )ONNX")

Method 2: Context-Dependent Function Body

For ops whose decomposition varies based on attributes or optional inputs:

cpp
static bool BuildFunctionBodyMyOp(
    const FunctionBodyBuildContext& ctx,
    const OpSchema& schema,
    FunctionProto& functionProto) {
  FunctionBuilder builder(functionProto);
  // Build graph based on ctx.hasInput(), ctx.getAttribute(), etc.
  builder.Add("output = SomeOp (input)");
  schema.BuildFunction(functionProto);
  return true;
}

// Register:
    .SetContextDependentFunctionBodyBuilder(BuildFunctionBodyMyOp)

FunctionBuilder API

cpp
FunctionBuilder builder(functionProto);
builder.Add("Y = Relu (X)");                          // Add node
builder.Const("alpha", std::vector<float>{0.01f});    // Constant tensor
builder.Const1D("axes", int64_t(1));                  // 1-D constant
builder.Add(R"(                                       // Multi-line
    X_Sub = Sub (X, X_Max)
    X_Exp = Exp (X_Sub)
)");
builder.AddOpset("", 18);                             // Opset dependency
schema.BuildFunction(functionProto);                  // Finalize
return true;

Multiple Opset Versions

cpp
    .SetContextDependentFunctionBodyBuilder(builderForOpset13)
    .SetContextDependentFunctionBodyBuilder(builderForOpset18, 18)

ONNX Function Body Syntax

Function body strings use the ONNX text format ("onnxtxt"). See the onnxtxt skill for the full syntax cheat sheet, attribute references (@attr_name), Constant <value = ...> forms, CastLike vs Cast, body-subgraph idioms, and parser tests. Quick reminders specific to function bodies:

  • Variable names are local intermediates; input/output names must match the schema's declared names.
  • Reference enclosing-op attributes with @attr_name — and only those declared in .Attr(...) calls.
  • Use CastLike (not Cast) when the target type depends on another input.

Code Style: Prefer Named Functions

Define context-dependent function body builders as separate named functions rather than inline lambdas within ONNX_OPERATOR_SET_SCHEMA. The macro expansion makes setting breakpoints on inline lambdas unreliable in debuggers.

Simple string-based .FunctionBody(R"ONNX(...)ONNX") definitions don't have this issue.

After Making Changes

bash
python onnx/defs/gen_doc.py
lintrunner -a --output oneline

Common Mistakes

  • Forgetting schema.BuildFunction(functionProto) at end of context-dependent builders
  • Forgetting to return true from the builder function
  • Variable names conflicting with input/output names
  • Using Cast instead of CastLike for dynamic type matching
  • Function body not producing all declared outputs
  • Using @attr_name for an attribute not declared in .Attr() calls

© onnx, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/add-function-body of onnx/onnx.

Open the folder on GitHubat commit ab429ea

Compare with similar skills

Add Function Body next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Add Function Body compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Add Function Body this skillonnx/onnx22k—~1.1kAutomated safety check: PassApache-2.0
Segment Anything Model GuideOrchestra-Research/AI-Research-SKILLs13k9 repos~3.3kAutomated safety check: PassMIT
Technology Selectiondotnet/skills5.6k2 repos~2.1kAutomated safety check: PassMIT
Quark Torch Quant Perfamd/Quark181—~3kAutomated safety check: PassMIT
Domain MLmajiayu000/claude-skill-registry6661 repos~1.2kAutomated safety check: PassMIT
Embedded AI Deploymentmatlab/agent-skills-playground1811 repos~3.4kAutomated safety check: PassCustom licence

Similar skills

  • Segment Anything Model Guide

    Orchestra-Research/AI-Research-SKILLs

    Guide to using Meta's Segment Anything Model for zero-shot image segmentation with point, box or mask prompts, or automatic mask generation.

    13k GitHub starsUsed in 9 repos~3.3k tokens
    AI & LLM EngineeringAuto-check passed
  • Official

    Guides technology selection and implementation of AI and ML features in .NET 8+ applications using ML.NET, Microsoft.Extensions.AI (MEAI), Microsoft Agent Framework (MAF), GitHub Copilot SDK, ONNX…

    5.6k GitHub starsUsed in 2 repos~2.1k tokens
    AI & LLM EngineeringAuto-check passed
  • Run, resume, monitor, diagnose, and report Quark Quant-Perf workflows for PyTorch and HuggingFace transformers models.

    181 GitHub stars~3k tokensUpdated 9 days ago
    AI & LLM EngineeringAuto-check passed
  • Domain ML

    majiayu000/claude-skill-registry

    A skill your agent uses when building ML/AI apps in Rust. An agent skill from majiayu000/claude-skill-registry.

    666 GitHub starsUsed in 1 repo~1.2k tokens
    Data & AnalyticsAuto-check passed
  • Embedded AI Deployment

    matlab/agent-skills-playground

    Deploy AI models to embedded hardware using MathWorks tools (MATLAB, Simulink, Embedded Coder).

    181 GitHub starsUsed in 1 repo~3.4k tokens
    AI & LLM EngineeringAuto-check passed
  • Model Builder

    qualcomm/qai-appbuilder

    QAI ModelBuilder. An agent skill from qualcomm/qai-appbuilder.

    246 GitHub stars~4.1k tokensUpdated today
    AI & LLM EngineeringAuto-check passed

More from onnx/onnx

  • Add Op

    onnx/onnx

    Add a new ONNX operator or update an existing operator to a new opset version.

    22k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Add or update type and shape inference for an ONNX operator.

    22k GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Onnxtxt

    onnx/onnx

    Read or write ONNX text format ("onnxtxt"). An agent skill from onnx/onnx.

    22k GitHub stars~1.3k tokensUpdated today
    Auto-check passed

Works with

Questions about Add Function Body

What does Add Function Body do?

Add a function body definition to an ONNX operator, defining how it decomposes into simpler ops. Add Function Body is an agent skill from onnx/onnx. Add a function body definition to an ONNX operator, defining how it decomposes into simpler ops.

When should I use Add Function Body?

Add Function Body fits situations like: asked to make an op decomposable; add a FunctionBody; implement SetContextDependentFunctionBodyBuilder; express an op in terms of other ONNX operators.

How do I install Add Function Body in Claude Code?

Run `npx skills add onnx/onnx --skill add-function-body -a claude-code`. Or copy the skill folder (.agents/skills/add-function-body in onnx/onnx) into .claude/skills/add-function-body in your project. Claude Code loads it when a task matches its description.

How do I install Add Function Body in Codex?

Run `npx skills add onnx/onnx --skill add-function-body -a codex`. Or copy the skill folder (.agents/skills/add-function-body in onnx/onnx) into .agents/skills/add-function-body in your project. Codex loads it when a task matches its description.

Can I use Add Function Body in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add onnx/onnx --skill add-function-body -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/add-function-body, .gemini/skills/add-function-body, .github/skills/add-function-body and .opencode/skills/add-function-body in your project.

What does Add Function Body need to run?

Going by SKILL.md and its folder, Add Function Body needs the command-line tools its instructions call (python). Our summary lists: Python 3.

Does Add Function Body access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Add Function Body safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Add Function Body use?

Add Function Body is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Add Function Body use?

About 1.1k tokens (SKILL.md is roughly 4.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Add Function Body?

Skills that share tags, products or a category with Add Function Body: Segment Anything Model Guide (Orchestra-Research/AI-Research-SKILLs, 13k stars), Technology Selection (dotnet/skills, 5.6k stars), Quark Torch Quant Perf (amd/Quark, 181 stars) and Domain ML (majiayu000/claude-skill-registry, 666 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Add Function Body?

onnx (a GitHub organization) maintains it in onnx/onnx, which has 21,562 GitHub stars. The repository holds 4 skills in this directory. The repository was last updated on October 7, 2026.

Source: onnx/onnx on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.