sglang: Skill for Claude Code

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

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

A step-by-step guide for adding a lightweight just-in-time compiled CUDA operation to SGLang. CUDA is NVIDIA's platform for running code on graphics processors, and just-in-time compilation builds the operation when it is first used.

In plain words
What is it for?
Use it to add an element-by-element tensor scaling operation that supports FP16, BF16, and FP32 data. It is intended for lightweight CUDA kernels that do not rely on large C++ projects, with stated exceptions for certain dependencies.
Why use it?
It gives developers a complete example and helps them decide whether a small operation belongs in the JIT system or in SGLang's heavier prebuilt C++ kernel system.

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 test/registered/kernels/benchmark/elementwise/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-jit-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-jit-kernel

README.md
[![agentmods](https://agentmods.dev/badge/skills/sgl-project/sglang/add-jit-kernel/github.svg)](https://agentmods.dev/skills/sgl-project/sglang/add-jit-kernel)
Your own site
<a href="https://agentmods.dev/skills/sgl-project/sglang/add-jit-kernel"><img src="https://agentmods.dev/badge/skills/sgl-project/sglang/add-jit-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-jit-kernel

Your own site · 80×15
<a href="https://agentmods.dev/skills/sgl-project/sglang/add-jit-kernel"><img src="https://agentmods.dev/badge/skills/sgl-project/sglang/add-jit-kernel.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 13,856 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 warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Prompt Injection · line 42
    Subtle instructions detected that may alter agent decision-making or introduce hidden biases.
    Fix: Review content for implicit steering or bias. Ensure instructions are explicit and align with the skill's stated purpose.
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.00032 $0.13856
Opus 5.5 $0.00013 $0.05542
Sonnet 5.5 $0.00006 $0.02771
Haiku 4.5 $0.00003 $0.01386

Measured 8d ago against content hash b2366f54cd9c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

add-jit-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 8d 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-jit-kernel/SKILL.md · 775 lines

How it starts

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

Tutorial: Adding a New JIT Kernel to SGLang

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 a JIT 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, passed at runtime)
  • Output: x * factor (element-wise), allocated internally
  • Supported dtypes: FP16 (torch.float16), BF16 (torch.bfloat16), FP32 (torch.float32)

When to use JIT vs AOT (sgl-kernel)

  • JIT (jit_kernel): prefer this first for kernels that do not depend on CUTLASS or another large C++ project. It is the default choice for lightweight kernels that benefit from rapid iteration and first-use compilation.
  • AOT (sgl-kernel): prefer this when the kernel does depend on CUTLASS or another large C++ project, or when it should live in python/sglang/kernels/aot/ and participate in the wheel build / torch op registration flow.
  • Exception: kernels that depend on flashinfer, or on CUTLASS that is already provided through flashinfer, can still be implemented as jit_kernel.

Conventions

These hold for every step below.

  • namespace sglang is where JIT code lives. Open it after the include block and close it at the end of the file, with the device kernels, traits and host wrapper inside. The shared host:: / device:: helpers are nested in it too, so they resolve unqualified. load_jit emits the TVM_FFI_DLL_EXPORT_TYPED_FUNC wrapper inside namespace sglang as well, so the kernel_name you pass from Python needs no sglang:: prefix.
  • Tuning policy belongs in Python; C++ gets the answer, not the decision. For a hyperparameter — split factor, threads per item, block size, vector width, an algorithm variant — prefer (not required) making it a template parameter and letting the @cache_once module factory choose the value, over a runtime if/switch in the launcher that picks among pre-instantiated kernels. The kernel then compiles exactly one specialisation and asserts its own preconditions with static_assert, while the heuristic that produced the value sits in Python where it is readable, adjustable, and inspectable without recompiling CUDA. store_cache's num_threads is the worked example: a get_kernel(num_split) ladder guarded by byte-alignment if constexprs became one template argument plus a heuristic in _jit_kvcache_module. The exception is a knob that genuinely varies per call with the runtime shape — that has to stay a kernel argument.
  • Check where the check is cheapest: static_assert > C++ host check > cached Python > per-call Python. Anything fixed at compile time is a static_assert. Anything about the tensors is a TensorMatcher / CHECK_HOST in the C++ launcher, free next to a kernel launch. A check Python cannot delegate goes inside the @cache_once module factory, where it runs once per specialisation. What remains in the per-call entry point costs interpreter time on every forward, so it should be nothing but picking the module and allocating out.
  • Fixed-width integer types. Prefer int32_t / int64_t / uint32_t / size_t over int, long, or long long, so an index has the same width on both sides of the FFI boundary. Bare int is fine only where the width plainly cannot matter — an unrolled loop counter over a constexpr bound, a template int parameter. Shapes arrive as int64_t (SymbolicSize::unwrap()); narrowing to uint32_t for in-kernel indexing is a deliberate act, so write the static_cast explicitly and only where the range is known.
  • Doxygen comments in C++. Document exported entities with /// or /** ... */ blocks using \brief, \param, \tparam, \return, the way include/sgl_kernel/ does. python -m sglang.kernels.jit writes CommentFormat: Doxygen into .clangd when clangd is 21 or newer, so these render on hover in the editor. Plain // remains fine for implementation notes inside a function body.
  • ASCII only in C++ and CUDA sources. Write --, ->, <= instead of —, →, ≤, including in comments. grep -nP '[^\x00-\x7F]' <file> before committing.
  • namespace details is private. Anything inside one is an implementation detail of its own header, free to change without notice. Do not name details:: from another module, and never using namespace details. If you find yourself wanting something in there, that is the signal to promote it to a documented name instead.
  • const T* __restrict__ for read-only pointers. This is what csrc/ does throughout, and it lets the compiler emit non-coherent (LDG) loads.
  • Watch the register budget. For memory-bound kernels, keep to roughly 64 registers per thread so occupancy does not become the limit; prefer recomputing a value over letting it spill. Run SGLANG_JIT_LOG_RESOURCE_USAGE=1 SGLANG_JIT_FORCE_RECOMPILE=1 to log per-kernel registers, spills and shared memory at INFO. Both halves are load-bearing: a cache hit has no compiler output to report, and passing -Xptxas -v by hand does nothing on its own because the build captures compiler output and replays it only on failure.
  • Alignment is a contract you enforce, not a property you hope for. A vectorized copy derives its access width from the row size (load_bytes picks 16B for a 1024B row), but the address it lands on is base + index * row_stride — and a stride is not constrained by the size. TensorMatcher admits any stride unless you say otherwise, so a padded cache row silently produces misaligned address. Every kernel that vectorizes is highly recommended to end its validation with .ensure_alignment(w), where w is the width the kernel actually uses.

Read the full file on GitHub · 775 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. 8d ago Changed b2366f54cd9c
  2. 1mo ago Changed · +2 lines 2494ad3d7b9f
  3. 1mo ago Changed · +30 lines · +5 tokens per session f634ff541bc9
  4. 1mo ago Changed · +37 lines a33f75c1066a
  5. 2mo ago First seen · 706 lines · 27 tokens per session scan A dce0427ee99d

Subscribe to this mod's changes

add-jit-kernel is a skill published in the GitHub repository sgl-project/sglang (38,324 stars, last pushed today), licensed Apache-2.0. It adds 32 tokens to every session and 13,856 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.

Related

Other skills, from other repositories

running-openmed-ondevice

Run OpenMed models fully on-device with the MLX (Apple Silicon), CoreML (iOS/macOS), or ONNX/WebGPU (cross-platform/browser) backends, including convert-quantize-run workflows. Use when the user wants to deploy OpenMed at the edge, run NER/de-id on Apple Silicon, target iPhone/iPad/Mac, export to ONNX or WebGPU…

maziyarpanahi/openmed · 175 tokens

opentrons-integration

Official Opentrons Protocol API for OT-2 and Flex robots. Use when writing protocols specifically for Opentrons hardware with full access to Protocol API v2 features. Best for production Opentrons protocols, official API compatibility. For multi-vendor automation or broader equipment control use pylabrobot.

synthetic-sciences/openscience · 66 tokens

groq-inference

Ultra-fast LLM inference on custom LPU hardware. OpenAI-compatible API at api.groq.com. Lowest latency in the industry (500-1000+ tok/s). Supports chat completions, vision, audio (Whisper STT + TTS), tool calling, JSON mode, and streaming. Free tier available. Inference only — no training.

synthetic-sciences/openscience · 77 tokens

pylabrobot

Vendor-agnostic lab automation framework. Use when controlling multiple equipment types (Hamilton, Tecan, Opentrons, plate readers, pumps) or needing unified programming across different vendors. Best for complex workflows, multi-vendor setups, simulation. For Opentrons-only protocols with official API…

synthetic-sciences/openscience · 73 tokens

openhue

Control Philips Hue lights, rooms, and scenes via the OpenHue CLI. Turn lights on/off, adjust brightness, color, color temperature, and activate scenes.

moltis-org/moltis · 35 tokens

eightctl

Control Eight Sleep pods (status, temperature, alarms, schedules).

moltis-org/moltis · 16 tokens