Skip to content

shafin027/xv6-riscv-skill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 xv6 RISC-V Expert

A Claude Code Skill for debugging, building, and mastering xv6 on 64-bit RISC-V

xv6 RISC-V Claude Code Skill Kernel Debugging MIT License

Syscalls Β· Schedulers Β· Page Tables Β· Traps Β· Locks Β· File System

Install Skill View on GitHub

GitHub stars GitHub forks GitHub issues License

πŸ“– What Is This?

xv6-riscv-expert is a Claude Code Skill designed for students and developers working with MIT-style xv6-riscv and SNU's xv6-riscv-snu operating system assignments.

✨ Perfect For:

Use Case Description
πŸŽ“ Coursework CSE321 / OS assignments (xv6-riscv)
πŸ”§ Kernel Dev System calls, scheduler, virtual memory
πŸ› Debugging Traps, page faults, locks
πŸ“š Learning OS concepts, RISC-V architecture

πŸš€ Quick Install

Option 1: One-Line Install (Recommended)

npx skills add shafin027/xv6-riscv-skill-

Option 2: Manual Install

git clone https://github.com/shafin027/xv6-riscv-skill-.git ~/.claude/skills/xv6-riscv-expert

Option 3: Local Project Install

cd /path/to/your/project
npx skills add shafin027/xv6-riscv-skill- --local

🎯 Usage

Slash Command

/xv6-riscv-expert

Automatic Triggering

Claude Code will use the skill when you ask questions like:

I need to add a new syscall to xv6-riscv.
How do I implement a lottery scheduler in xv6?
Debug this xv6 page fault: scause=15, stval=0x0.

πŸ› οΈ Supported Assignment Types

Type Examples Status
System Calls settickets, getpid, tracing, custom syscalls βœ…
Scheduler Lottery scheduler, priority scheduler, round-robin βœ…
Virtual Memory Page tables, PTEs, vmprint, COW, USYSCALL βœ…
Traps & Interrupts usertrap, page faults, timer interrupts βœ…
Process Management fork, exit, wait, process states βœ…
Locks & Concurrency Spinlocks, sleeplocks, race conditions βœ…
File System Inodes, logging, buffer cache βœ…

πŸ“š Skill Knowledge Base

Core Files Map

File Purpose
kernel/proc.h struct proc, process states, fields
kernel/proc.c Process lifecycle, scheduler, fork, exit
kernel/syscall.c Syscall dispatcher and table
kernel/syscall.h Syscall numbers
kernel/trap.c Trap handling, interrupts, exceptions
kernel/vm.c Page tables, virtual memory, mapping
kernel/riscv.h RISC-V registers, PTE flags
user/user.h User-space function declarations

🎯 Answer Templates

Implementation Answer:

  1. Files to change
  2. Patch / code
  3. Why this works
  4. How to test
  5. Common mistakes

Debugging Answer:

  1. Likely cause
  2. What to inspect
  3. Exact command(s)
  4. Fix
  5. Validation

🎯 Example Workflows

Example 1: Adding a New Syscall

Prompt:

I need to add a syscall called settickets(int n) to xv6-riscv

Skill Response:

  • βœ… Lists all files to change
  • βœ… Provides exact code patches
  • βœ… Explains why each change works
  • βœ… Gives test commands (make qemu)
  • βœ… Shows common mistakes to avoid

Example 2: Lottery Scheduler Assignment

Prompt:

Implement a lottery scheduler for xv6-riscv where each process 
has tickets and the scheduler picks a random winner

Skill Response:

  • βœ… Step-by-step implementation plan
  • βœ… Complete code for proc.h, proc.c, sysproc.c
  • βœ… Random number generator implementation
  • βœ… Test program (test_scheduler.c)
  • βœ… Patch file creation instructions

Example 3: Debugging a Page Fault

Prompt:

My xv6 kernel panics with scause=15 (store page fault). 
The fault happens in sys_write. Here's my code...

Skill Response:

  • βœ… Identifies likely cause (PTE permissions, user pointer)
  • βœ… Shows what to inspect (copyout, walk(), PTE flags)
  • βœ… Provides exact fix
  • βœ… Gives validation steps

πŸ”§ xv6-riscv Setup

Before using this skill, ensure you have xv6-riscv set up:

1. Install Prerequisites

# Ubuntu/Debian
sudo apt update
sudo apt install git build-essential gdb-multiarch qemu-system-misc \
                 gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu

2. Clone xv6-riscv

git clone https://github.com/mit-pdos/xv6-riscv.git
cd xv6-riscv

3. Build and Run

make clean
make qemu

4. Debug with GDB

Terminal 1:

make qemu-gdb

Terminal 2:

riscv64-linux-gnu-gdb kernel/kernel

πŸ“‹ Assignment Checklist

When working on xv6 assignments, the skill will help you:

  • Identify assignment type
  • List all files to modify
  • Provide minimal correct patches
  • Explain why the solution works
  • Include test commands
  • Warn about common mistakes
  • Help create patch files (git diff --staged > ID.patch)

🀝 Contributing

Found a bug or want to improve the skill? Contributions welcome!

  1. Fork the repo
  2. Create your feature branch (git checkout -b feature/amazing-improvement)
  3. Commit your changes (git commit -m 'Add some amazing improvement')
  4. Push to the branch (git push origin feature/amazing-improvement)
  5. Open a Pull Request

Star History

Star History Chart

πŸ“„ License

MIT License β€” feel free to use, modify, and distribute.


πŸ”— Resources


πŸ’¬ Support

Having issues?

  1. Open an issue on GitHub
  2. Ask in the Claude Code Discord

Made with ❀️ for OS students, xv6 hackers, and RISC-V enthusiasts

Part of the Claude Code Skills ecosystem

Releases

No releases published

Packages

 
 
 

Contributors