/linux-kernel-modules
Linux kernel module skill for writing and debugging loadable kernel modules. Use when writing LKMs with Kbuild, adding module parameters, creating /proc and sysfs entries, implementing character devices, debugging with KGDB or ftrace, or handling module signing for Secure Boot.
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill linux-kernel-modules --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/linux-kernel-modules
Context preview
The summary Claude sees to decide when to auto-load this skill.
Linux kernel module skill for writing and debugging loadable kernel modules. Use when writing LKMs with Kbuild, adding module parameters, creating /proc and sysfs entries, implementing character devices, debugging with KGDB or ftrace, or handling module signing for Secure Boot.
SKILL.md
linux-kernel-modules.SKILL.mdname: linux-kernel-modules
description: Linux kernel module skill for writing and debugging loadable kernel modules. Use when writing LKMs with Kbuild, adding module parameters, creating /proc and sysfs entries, implementing character devices, debugging with KGDB or ftrace, or handling module signing for Secure Boot. Activates on queries about Linux kernel modules, loadable modules, Kbuild, module parameters, /proc filesystem, sysfs, character devices, KGDB, or module signing.
Linux Kernel Modules
Purpose
Guide agents through writing loadable Linux kernel modules (LKMs): the Kbuild build system, module parameters, /proc and sysfs interfaces, character device implementation, kernel debugging with KGDB and `ftrace`, and module signing for Secure Boot.
Triggers
- "How do I write a Linux kernel module?"
- "How do I add parameters to my kernel module?"
- "How do I create a /proc or sysfs entry?"
- "How do I implement a character device driver?"
- "How do I debug a kernel module with KGDB?"
- "How do I sign a kernel module for Secure Boot?"
Workflow
1. Minimal kernel module
// hello.c — minimal loadable kernel module
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Your Name");
MODULE_DESCRIPTION("Minimal hello world module");
MODULE_VERSION("1.0");
static int __init hello_init(void)
{
printk(KERN_INFO "hello: module loaded\n");
return 0; // non-zero = load failure
}
static void __exit hello_exit(void)
{
printk(KERN_INFO "hello: module unloaded\n");
}
module_init(hello_init);
module_exit(hello_exit);# Makefile — must be exactly this structure for Kbuild
obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
# Build
make
# Load
sudo insmod hello.ko
# Check it loaded
lsmod | grep hello
dmesg | tail -5 # see printk output
# Unload
sudo rmmod hello
# Show module info
modinfo hello.ko
2. Module parameters
#include <linux/moduleparam.h>
static int count = 1;
static char *name = "world";
// module_param(variable, type, permissions)
// permissions: 0 = no sysfs entry, S_IRUGO = readable, S_IWUSR = writable
module_param(count, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(count, "Number of times to print (default: 1)");
module_param(name, charp, S_IRUGO);
MODULE_PARM_DESC(name, "Name to greet (default: world)");
static int __init hello_init(void)
{
int i;
for (i = 0; i < count; i++)
printk(KERN_INFO "hello: Hello, %s!\n", name);
return 0;
}# Pass parameters at load time
sudo insmod hello.ko count=3 name="kernel"
# Modify at runtime (if S_IWUSR set)
echo 5 > /sys/module/hello/parameters/count
3. /proc filesystem interface
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
static struct proc_dir_entry *proc_entry;
static int mymod_show(struct seq_file *m, void *v)
{
seq_printf(m, "Counter: %d\n", my_counter);
seq_printf(m, "Status: %s\n", my_status ? "active" : "idle");
return 0;
}
static int mymod_open(struct inode *inode, struct file *file)
{
return single_open(file, mymod_show, NULL);
}
static const struct proc_ops mymod_fops = {
.proc_open = mymod_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = single_release,
};
static int __init mymod_init(void)
{
proc_entry = proc_create("mymod", 0444, NULL, &mymod_fops);
if (!proc_entry)
return -ENOMEM;
return 0;
}
static void __exit mymod_exit(void)
{
proc_remove(proc_entry);
}cat /proc/mymod
4. sysfs interface
#include <linux/kobject.h>
#include <linux/sysfs.h>
static struct kobject *mymod_kobj;
static int mymod_value = 42;
static ssize_t value_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", mymod_value);
}
static ssize_t value_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
{
sscanf(buf, "%d", &mymod_value);
return count;
}
static struct kobj_attribute value_attr =
__ATTR(value, 0664, value_show, value_store);
static int __init mymod_init(void)
{
mymod_kobj = kobject_create_and_add("mymod", kernel_kobj);
if (!mymod_kobj) return -ENOMEM;
return sysfs_create_file(mymod_kobj, &value_attr.attr);
}
static void __exit mymod_exit(void)
{
sysfs_remove_file(mymod_kobj, &value_attr.attr);
kobject_put(mymod_kobj);
}cat /sys/kernel/mymod/value
echo 100 > /sys/kernel/mymod/value
5. Character device
#include <linux/cdev.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#define DEVICE_NAME "mydev"
#define BUF_SIZE 1024
static int major;
static struct cdev my_cdev;
static char kernel_buf[BUF_SIZE];
static int mydev_open(struct inode *inode, struct file *file) { return 0; }
static int mydev_release(struct inode *inode, struct file *file) { return 0; }
static ssize_t mydev_read(struct file *f, char __user *buf, size_t len, loff_t *off)
{
size_t to_copy = min(len, (size_t)BUF_SIZE);
if (copy_to_user(buf, kernel_buf, to_copy)) return -EFAULT;
return to_copy;
}
static ssize_t mydev_write(struct file *f, const char __user *buf, size_t len, loff_t *off)
{
size_t to_copy = min(len, (size_t)(BUF_SIZE - 1));
if (copy_from_user(kernel_buf, buf, to_copy)) return -EFAULT;
kernel_buf[to_copy] = '\0';
return to_copy;
}
static const struct file_operations mydev_fops = {
.owner = THIS_MODULE,
.open = mydev_open,
.release = mydev_release,
.read = mydev_read,
.write = mydev_write,
};
static int __init mydev_init(void)
{
major = register_chrdev(0, DEVICE_NAME, &mydev_fops);
if (major < 0) return major;
printk(KERN_INFO "mydev: registered with majoRead more
name: linux-kernel-modules description: Linux kernel module skill for writing and debugging loadable kernel modules. Use when writing LKMs with Kbuild, adding module parameters, creating /proc and sysfs entries, implementing character devices, debugging with KGDB or ftrace, or handling module signing for Secure Boot. Activates on queries about Linux kernel modules, loadable modules, Kbuild, module parameters, /proc filesystem, sysfs, character devices, KGDB, or module signing.
Linux Kernel Modules
Purpose
Guide agents through writing loadable Linux kernel modules (LKMs): the Kbuild build system, module parameters, /proc and sysfs interfaces, character device implementation, kernel debugging with KGDB and `ftrace`, and module signing for Secure Boot.
Triggers
- "How do I write a Linux kernel module?"
- "How do I add parameters to my kernel module?"
- "How do I create a /proc or sysfs entry?"
- "How do I implement a character device driver?"
- "How do I debug a kernel module with KGDB?"
- "How do I sign a kernel module for Secure Boot?"
Workflow
1. Minimal kernel module
// hello.c — minimal loadable kernel module
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Your Name");
MODULE_DESCRIPTION("Minimal hello world module");
MODULE_VERSION("1.0");
static int __init hello_init(void)
{
printk(KERN_INFO "hello: module loaded\n");
return 0; // non-zero = load failure
}
static void __exit hello_exit(void)
{
printk(KERN_INFO "hello: module unloaded\n");
}
module_init(hello_init);
module_exit(hello_exit);# Makefile — must be exactly this structure for Kbuild obj-m := hello.o KDIR := /lib/modules/$(shell uname -r)/build all: $(MAKE) -C $(KDIR) M=$(PWD) modules clean: $(MAKE) -C $(KDIR) M=$(PWD) clean
# Build make # Load sudo insmod hello.ko # Check it loaded lsmod | grep hello dmesg | tail -5 # see printk output # Unload sudo rmmod hello # Show module info modinfo hello.ko
2. Module parameters
#include <linux/moduleparam.h>
static int count = 1;
static char *name = "world";
// module_param(variable, type, permissions)
// permissions: 0 = no sysfs entry, S_IRUGO = readable, S_IWUSR = writable
module_param(count, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(count, "Number of times to print (default: 1)");
module_param(name, charp, S_IRUGO);
MODULE_PARM_DESC(name, "Name to greet (default: world)");
static int __init hello_init(void)
{
int i;
for (i = 0; i < count; i++)
printk(KERN_INFO "hello: Hello, %s!\n", name);
return 0;
}# Pass parameters at load time sudo insmod hello.ko count=3 name="kernel" # Modify at runtime (if S_IWUSR set) echo 5 > /sys/module/hello/parameters/count
3. /proc filesystem interface
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
static struct proc_dir_entry *proc_entry;
static int mymod_show(struct seq_file *m, void *v)
{
seq_printf(m, "Counter: %d\n", my_counter);
seq_printf(m, "Status: %s\n", my_status ? "active" : "idle");
return 0;
}
static int mymod_open(struct inode *inode, struct file *file)
{
return single_open(file, mymod_show, NULL);
}
static const struct proc_ops mymod_fops = {
.proc_open = mymod_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = single_release,
};
static int __init mymod_init(void)
{
proc_entry = proc_create("mymod", 0444, NULL, &mymod_fops);
if (!proc_entry)
return -ENOMEM;
return 0;
}
static void __exit mymod_exit(void)
{
proc_remove(proc_entry);
}cat /proc/mymod
4. sysfs interface
#include <linux/kobject.h>
#include <linux/sysfs.h>
static struct kobject *mymod_kobj;
static int mymod_value = 42;
static ssize_t value_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", mymod_value);
}
static ssize_t value_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
{
sscanf(buf, "%d", &mymod_value);
return count;
}
static struct kobj_attribute value_attr =
__ATTR(value, 0664, value_show, value_store);
static int __init mymod_init(void)
{
mymod_kobj = kobject_create_and_add("mymod", kernel_kobj);
if (!mymod_kobj) return -ENOMEM;
return sysfs_create_file(mymod_kobj, &value_attr.attr);
}
static void __exit mymod_exit(void)
{
sysfs_remove_file(mymod_kobj, &value_attr.attr);
kobject_put(mymod_kobj);
}cat /sys/kernel/mymod/value echo 100 > /sys/kernel/mymod/value
5. Character device
#include <linux/cdev.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#define DEVICE_NAME "mydev"
#define BUF_SIZE 1024
static int major;
static struct cdev my_cdev;
static char kernel_buf[BUF_SIZE];
static int mydev_open(struct inode *inode, struct file *file) { return 0; }
static int mydev_release(struct inode *inode, struct file *file) { return 0; }
static ssize_t mydev_read(struct file *f, char __user *buf, size_t len, loff_t *off)
{
size_t to_copy = min(len, (size_t)BUF_SIZE);
if (copy_to_user(buf, kernel_buf, to_copy)) return -EFAULT;
return to_copy;
}
static ssize_t mydev_write(struct file *f, const char __user *buf, size_t len, loff_t *off)
{
size_t to_copy = min(len, (size_t)(BUF_SIZE - 1));
if (copy_from_user(kernel_buf, buf, to_copy)) return -EFAULT;
kernel_buf[to_copy] = '\0';
return to_copy;
}
static const struct file_operations mydev_fops = {
.owner = THIS_MODULE,
.open = mydev_open,
.release = mydev_release,
.read = mydev_read,
.write = mydev_write,
};
static int __init mydev_init(void)
{
major = register_chrdev(0, DEVICE_NAME, &mydev_fops);
if (major < 0) return major;
printk(KERN_INFO "mydev: registered with majoA curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Repo: mohitmishra786/low-level-dev-skills
Other skills on low-level-dev-skills.
- /custom-allocators
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning jemalloc/mimalloc, writing Rust GlobalAlloc, or benchmarking allocator performance. Activates on queries about jemalloc, mimalloc, tcmalloc, arena allocator,
Open skill - /numa-programming
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using libnuma API, building NUMA-aware data structures, or measuring remote access penalties. Activates on queries about numactl, libnuma, NUMA topology,
Open skill - /af-xdp
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT programs, copy vs zero-copy mode, or comparing with DPDK. Activates on queries about AF_XDP, xsk_umem, XDP_REDIRECT, libbpf xsk, or zero-copy XDP.
Open skill - /dpdk
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting up huge pages, RSS, or testpmd validation. Activates on queries about DPDK, EAL, rte_eth_rx_burst, hugepages, PMD, or testpmd.
Open skill - /io-uring
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided buffers, fixed files, zero-copy send, or tokio-uring. Activates on queries about io_uring, SQE/CQE, liburing, IORING_OP_PROVIDE_BUFFERS, or io_uring vs
Open skill - /adc-dac-baremetal
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates on queries about ADC bare-metal, sampling time, DMA ADC, or DAC channel setup.
Open skill

