add-cuda-kernel

add-cuda-kernel is a skill for Claude Code, Codex from KJLdefeated/RL.cu. It costs 20 tokens per session (10,552 once invoked), scanned C, original, MIT.

A guide for adding a new compute kernel to RL.cu, a project that uses CUDA or C++ code for calculations on graphics processors. It specifies source, header, test, and build files.

In plain words
What is it for?
Use it to add CUDA or equivalent C++ kernels, create their tests, update the Makefile, and explain how the implementation works.
Why use it?
It provides a fixed layout and test expectation so new kernels can be compiled and checked in the same way as existing ones.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/kjldefeated/rl.cu/add_new_kernel
Any agent
npx skills add KJLdefeated/RL.cu --skill add_new_kernel
Clone the repo
git clone --depth 1 https://github.com/KJLdefeated/RL.cu

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-cuda-kernel

README.md
[![agentmods](https://agentmods.dev/badge/skills/kjldefeated/rl.cu/add_new_kernel.svg)](https://agentmods.dev/skills/kjldefeated/rl.cu/add_new_kernel)
Your own site
<a href="https://agentmods.dev/skills/kjldefeated/rl.cu/add_new_kernel"><img src="https://agentmods.dev/badge/skills/kjldefeated/rl.cu/add_new_kernel.svg" alt="Measured on agentmods" height="20"></a>
Per session 20 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 10,552 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
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 $0.00020 $0.10552
Opus 5 $0.00010 $0.05276
Sonnet 5 $0.00004 $0.02110
Haiku 4.5 $0.00002 $0.01055

Measured 4d ago against content hash ef72202b70ef, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

add-cuda-kernel scanned grade C with 1 finding 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 4d 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf $(BUILDDIR)
.claude/skills/add_new_kernel/SKILL.md · 966 lines

How it starts

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

Tutorial: Adding a New Kernel to RL.cu

Goal

Implement high performance cuda kernel with target format:

  • include files: include/kernels/[kernel_name].cuh
  • source files: src/kernels/[kernel_name].cu
  • testing: tests/test_[kernel_name].cu
  • Makefile: Compile the testing implementation Same format for non-cuda function (e.g. cpp) After finsihed implementation, you should explain how the kernel works.

Example

include/kernels/attention.cuh — Flash Attention 2 Kernel

#pragma once

#include <cuda_fp16.h>
#include <cuda_runtime.h>

// ---------------------------------------------------------------------------
// Flash Attention 2 — Prefill
// ---------------------------------------------------------------------------
// Q, K, V layout: [B, S, H, D]  (H = num_heads, D = head_dim)
// O       layout: [B, S, H_q, D]
//
// GQA supported: H_q % H_kv == 0.  kv_head = q_head * H_kv / H_q.
// Causal mask applied (token i attends only to positions <= i).
// FP16 I/O, FP32 accumulation.  Currently specialised for head_dim = 128.
//
// Tile sizes: Br=16 (Q rows per block), Bc=64 (KV cols per tile).
// Shared memory per block: 2 × Bc × D × sizeof(half) = 32 KB.
// ---------------------------------------------------------------------------
void launch_flash_attention_prefill(
    const half*  Q,
    const half*  K,
    const half*  V,
    half*        O,
    int B, int S, int H_q, int H_kv, int head_dim,
    cudaStream_t stream = 0
);

// ---------------------------------------------------------------------------
// Paged Attention — Decode
// ---------------------------------------------------------------------------
// Single new token (S_q=1) attends to full context stored in a paged KV cache.
//
// q layout:              [num_seqs, H_q, D]
// k_cache / v_cache:     [num_blocks, H_kv, block_size, D]
// block_tables:          [num_seqs, max_blocks_per_seq]   (logical→physical)
// seq_lens:              [num_seqs]  — context length including the new token
//
// Specialised for head_dim=128, block_size=16.
// ---------------------------------------------------------------------------
void launch_paged_attention_decode(
    const half*  q,
    const half*  k_cache,
    const half*  v_cache,
    half*        out,
    const int*   block_tables,
    const int*   seq_lens,
    int num_seqs, int H_q, int H_kv, int head_dim,
    int max_blocks_per_seq, int block_size,
    cudaStream_t stream = 0
);

Read the full file on GitHub · 966 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. 4d ago First seen · 966 lines · 20 tokens per session scan C ef72202b70ef

Subscribe to this mod's changes

add-cuda-kernel is a skill published in the GitHub repository KJLdefeated/RL.cu (42 stars, last pushed 1mo ago), licensed MIT. It adds 20 tokens to every session and 10,552 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.