sglang: Skill for Claude Code

.agents/skills/add-sgl-kernel/SKILL.md

add-sgl-kernel is a skill for Claude Code, Codex from sgl-project/sglang. It costs 31 tokens per session (3,592 once invoked), scanned A, original, Apache-2.0.

A step-by-step guide for adding a heavyweight ahead-of-time compiled CUDA/C++ operation to SGLang's kernel package. Ahead-of-time compilation builds the kernel before use, and CUDA runs the operation on NVIDIA graphics processors.

In plain words
What is it for?
Use it to add an element-by-element tensor scaling kernel supporting FP16, BF16, and FP32 data. It is intended for operations that depend on large C++ projects such as CUTLASS or must be included in the prebuilt package and PyTorch operation registration flow.
Why use it?
It shows the required implementation, test, and benchmark workflow for kernels that belong in the prebuilt system. It also helps distinguish these kernels from lighter operations that should use SGLang's JIT path.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

This is sgl-project/sglang's own configuration. It tells Claude Code and Codex how to work on sglang itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything sglang configures →

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is python python/sglang/kernels/aot/benchmark/bench_scale.py.

About the project

SGLang is a framework for running inference for large language models and multimodal models, meaning it processes inputs to produce model outputs such as text or other media. It is used to serve and accelerate open AI models and related workloads.

sgl-project/sglang · 38,324 stars · on GitHub · sglang.io

Reuse

Borrowing it

Nothing to install: this file belongs to sgl-project/sglang. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/sgl-project/sglang/main/.agents/skills/add-sgl-kernel/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/sgl-project/sglang

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for add-sgl-kernel

README.md
[![agentmods](https://agentmods.dev/badge/skills/sgl-project/sglang/add-sgl-kernel/github.svg)](https://agentmods.dev/skills/sgl-project/sglang/add-sgl-kernel)
Your own site
<a href="https://agentmods.dev/skills/sgl-project/sglang/add-sgl-kernel"><img src="https://agentmods.dev/badge/skills/sgl-project/sglang/add-sgl-kernel/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for add-sgl-kernel

Your own site · 80×15
<a href="https://agentmods.dev/skills/sgl-project/sglang/add-sgl-kernel"><img src="https://agentmods.dev/badge/skills/sgl-project/sglang/add-sgl-kernel.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,592 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Snyk pass 7 Sept 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00031 $0.03592
Opus 5.5 $0.00012 $0.01437
Sonnet 5.5 $0.00006 $0.00718
Haiku 4.5 $0.00003 $0.00359

Measured 1mo ago against content hash 841317903dcd, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

add-sgl-kernel scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/add-sgl-kernel/SKILL.md · 371 lines

How it starts

The opening of the file, as written. The whole thing — 371 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Tutorial: Adding a New Kernel to sgl-kernel (AOT / Heavyweight)

Apply kernel-organization for the public operator namespace, logical grouping, lazy registry metadata, and test placement. The implementation tutorial below does not replace that API contract.

This tutorial walks through adding a simple element-wise scale operation as an AOT kernel. We'll implement scale(x, factor) = x * factor to demonstrate the complete workflow.

Goal

Add a new operation that scales each element of a tensor by a scalar factor:

  • Input: tensor x (CUDA) and scalar factor (float)
  • Output: x * factor (element-wise, in-place or into pre-allocated out)
  • Supported dtypes: FP16 (torch.float16), BF16 (torch.bfloat16), FP32 (torch.float32)
    • Dispatched via DISPATCH_PYTORCH_DTYPE_TO_CTYPE_FLOAT_FP16 macro (defined in python/sglang/kernels/aot/include/utils.h)

Two rules of thumb (must follow)

  1. Prefer python/sglang/kernels/jit first when the kernel does not depend on CUTLASS or another large C++ project. This is the default path for lightweight kernels that benefit from rapid iteration.
  2. Prefer sgl-kernel when the kernel does depend on CUTLASS or another large C++ project, or when it should be part of the AOT wheel / torch op registration flow.
  3. Exception: if the dependency is flashinfer, or CUTLASS that is already provided through flashinfer, the kernel can still be implemented as jit_kernel.

In addition, every new kernel must ship with:

  • Tests (pytest)
  • A benchmark script (marker.do_bench from sglang.kernels.jit.benchmark — it works for any callable, not only JIT kernels)

Repository integration map

You will typically touch these files/areas:

  • Implementation: python/sglang/kernels/aot/csrc/elementwise/scale.cu (pick the right subdirectory)
  • Public declarations: python/sglang/kernels/aot/include/sgl_kernel_ops.h
  • Torch extension registration: python/sglang/kernels/aot/csrc/common_extension.cc
  • Build: python/sglang/kernels/aot/CMakeLists.txt (set(SOURCES ...))
  • Python API: python/sglang/kernels/aot/python/sgl_kernel/ and python/sglang/kernels/aot/python/sgl_kernel/__init__.py
  • Tests: python/sglang/kernels/aot/tests/test_scale.py
  • Benchmarks: python/sglang/kernels/aot/benchmark/bench_scale.py

Read the full file on GitHub · 371 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed · -16 lines 841317903dcd
  2. 1mo ago Changed · +19 lines b5b1e2ed4d92
  3. 2mo ago First seen · 368 lines · 31 tokens per session scan A 1560d3d9f4c9

Subscribe to this mod's changes

add-sgl-kernel is a skill published in the GitHub repository sgl-project/sglang (38,324 stars, last pushed today), licensed Apache-2.0. It adds 31 tokens to every session and 3,592 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.