mojo-max
Comprehensive support for Mojo programming, GPU kernels, and AI deployment using the MAX framework.
Install
mkdir -p .claude/skills/mojo-max && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/9734" && unzip -o skill.zip -d .claude/skills/mojo-max && rm skill.zipInstalls to .claude/skills/mojo-max
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Comprehensive Mojo programming language and MAX framework development skill. Use when: (1) Writing Mojo code - systems programming with Python-like syntax (2) Translating Python code to high-performance Mojo (3) GPU kernel development - NVIDIA, AMD, Apple silicon (4) Using MAX for AI model deployment and inference (5) Working with SIMD, parallelism, or low-level memory management (6) Questions about Mojo ownership, structs, traits, or pointers Triggers: .mojo files, "mojo", "MAX framework", "GPU kernel", "SIMD", "LayoutTensor", mentions of ModularKey capabilities
- →Translate Python code to Mojo
- →Develop GPU kernels for AI inference
- →Write SIMD-optimized systems code
- →Manage memory with ownership and borrowing
- →Deploy AI models using the MAX framework
How it works
The skill guides the translation of Python syntax into Mojo's strict, performant systems language features and provides patterns for GPU and SIMD optimization.
Inputs & outputs
When to use mojo-max
- →Translating Python to Mojo
- →Developing GPU kernels
- →Writing SIMD-optimized code
- →Using MAX framework for AI
About this skill
Mojo & MAX Development Skill
Mojo is a systems programming language combining Python syntax with C-level performance. MAX is Modular's AI deployment framework. This skill helps translate Python expertise into idiomatic, high-performance Mojo code.
Important: Searching the Modular Repository
When the user asks to search through Modular source code, documentation, or examples, or when you need to find specific implementation details, API usage patterns, or real-world examples not covered in these references: Repo path: repos/modular
- Ask the user for the repository path if not already provided
- Search the repository using
view,search,file_searchandbashtools to explore:stdlib/- Mojo standard library source codeexamples/- Official code examplesdocs/- Documentation sourcemax/- MAX framework implementationmojo/- Mojo compiler and language features
- Use grep/find to locate specific functions, structs, or patterns:
# Find all uses of a function grep -r "vectorize" /path/to/repo --include="*.mojo" # Find struct definitions grep -r "struct DeviceContext" /path/to/repo --include="*.mojo" # Find examples find /path/to/repo/examples -name "*.mojo" | xargs grep "pattern" - Examine test files for usage patterns - they often show correct API usage
- Check proposals/ for upcoming features and design rationale
Always prefer real source code examples over generated code when available.
If user asks specifically to search internet, or if even after searching the repository, unable to find the answer then you can search internet for the answer.
Quick Reference: Python → Mojo
| Python | Mojo | Notes |
|---|---|---|
def func(): | fn func(): | fn = strict, def = flexible |
x = 5 | var x: Int = 5 | Static typing required in fn |
class Foo: | struct Foo: | Value semantics, no inheritance |
def __init__(self): | fn __init__(out self): | out modifier required |
list[int] | List[Int] | Capitalized types |
| GC manages memory | Ownership + ^ transfer | Manual control |
ValueError | Error | Different error types |
| Dynamic typing | Progressive static typing | Types enforced at compile |
Core Workflow
1. Choose Function Style
# def - Python-like, flexible, implicit raises
def greet(name):
return "Hello, " + name
# fn - strict, performant, explicit types required
fn greet(name: String) -> String:
return "Hello, " + name
Use fn for performance-critical code. Use def for prototyping or Python interop.
2. Understand Argument Conventions
| Convention | Syntax | Behavior |
|---|---|---|
read | fn f(x: Int) | Immutable reference (default for fn) |
mut | fn f(mut x: Int) | Mutable reference, changes visible to caller |
owned | fn f(owned x: String) | Takes ownership, use ^ to transfer |
out | fn __init__(out self) | Uninitialized, must be initialized |
3. Define Structs with Proper Lifecycle
@fieldwise_init # Auto-generates field-wise constructor
struct Point(Copyable, Stringable):
var x: Float64
var y: Float64
fn __str__(self) -> String:
return "(" + str(self.x) + ", " + str(self.y) + ")"
4. Transfer Ownership with ^
fn consume(owned s: String):
print(s)
fn main():
var msg = "Hello"
consume(msg^) # Transfer ownership
# msg is now uninitialized - cannot use
When to Read Reference Files
| Task | Reference File |
|---|---|
| Learning fn/def, var, types, structs, traits | language-basics.md |
| Understanding ownership, borrowing, lifetimes | ownership-memory.md |
| Working with pointers (Pointer, UnsafePointer, etc.) | pointers.md |
| SIMD, vectorize, parallelize, compile-time | performance-cpu.md |
| GPU kernels, DeviceContext, grids/blocks | gpu-programming.md |
| LayoutTensor, TensorCores, shared memory | gpu-advanced.md |
| Calling Python from Mojo or vice versa | python-interop.md |
| MAX Serve, inference, model deployment | max-framework.md |
| Common pitfalls, translation patterns | translation-patterns.md |
Essential Patterns
SIMD Vectorization
from algorithm.functional import vectorize
alias simd_width = simdwidthof[DType.float32]()
fn process(data: UnsafePointer[Float32], size: Int):
@parameter
fn op[width: Int](i: Int):
var v = data.load[width=width](i)
data.store[width=width](i, v * 2.0)
vectorize[op, simd_width](size)
Parallel Execution
from algorithm.functional import parallelize
fn parallel_work():
@parameter
fn task(i: Int):
compute(i)
parallelize[task](num_tasks)
Basic GPU Kernel
from gpu.host import DeviceContext
from gpu import block_idx, thread_idx, global_idx
fn vector_add(out: UnsafePointer[Float32, MutAnyOrigin],
a: UnsafePointer[Float32, MutAnyOrigin],
b: UnsafePointer[Float32, MutAnyOrigin],
size: Int):
var idx = global_idx.x
if idx < size:
out[idx] = a[idx] + b[idx]
def main():
ctx = DeviceContext()
# ... allocate buffers, copy data ...
ctx.enqueue_function[vector_add, vector_add](
out_buf, a_buf, b_buf, size,
grid_dim=((size + 255) // 256,),
block_dim=(256,)
)
ctx.synchronize()
Python Interop
from python import Python
def use_numpy():
np = Python.import_module("numpy")
arr = np.array([1, 2, 3, 4, 5])
print(arr.mean())
Common Pitfalls
- No top-level code - wrap in
def main(): - Constructor needs
out self-fn __init__(out self): letremoved - use onlyvar- Types are capitalized -
Int,String,Float64 - No list comprehensions - use explicit loops
- Error not ValueError -
raise Error("msg") - Struct not class - value semantics, no inheritance
File Organization
project/
├── main.mojo # Entry point with def main()
├── utils.mojo # Helper functions/structs
└── pixi.toml # Package management (recommended)
Build & Run
# Using pixi (recommended)
pixi init
pixi add max
pixi run mojo main.mojo
# Direct execution
mojo main.mojo
# Compile to binary
mojo build main.mojo -o app
./app
When not to use it
- →When top-level code is required without a main function
- →When inheritance-based class structures are needed
Prerequisites
Limitations
- →No support for class inheritance
- →No support for list comprehensions
How it compares
It focuses on performance-critical systems programming and hardware-specific optimizations rather than general-purpose Python development.
Compared to similar skills
mojo-max side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| mojo-max (this skill) | 0 | 6mo | Review | Advanced |
| unsloth | 15 | 8mo | No flags | Intermediate |
| llm-application-dev | 3 | 4mo | Review | Intermediate |
| book-sft-pipeline | 3 | 2mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by MVPavan
View all by MVPavan →You might also like
unsloth
zechenzhangAGI
Expert guidance for fast fine-tuning with Unsloth - 2-5x faster training, 50-80% less memory, LoRA/QLoRA optimization
llm-application-dev
skillcreatorai
Building applications with Large Language Models - prompt engineering, RAG patterns, and LLM integration. Use for AI-powered features, chatbots, or LLM-based automation.
book-sft-pipeline
muratcankoylan
This skill should be used when the user asks to "fine-tune on books", "create SFT dataset", "train style model", "extract ePub text", or mentions style transfer, LoRA training, book segmentation, or author voice replication.
fine-tuning-with-trl
davila7
Fine-tune LLMs using reinforcement learning with TRL - SFT for instruction tuning, DPO for preference alignment, PPO/GRPO for reward optimization, and reward model training. Use when need RLHF, align model with preferences, or train from human feedback. Works with HuggingFace Transformers.
huggingface-tokenizers
davila7
Fast tokenizers optimized for research and production. Rust-based implementation tokenizes 1GB in <20 seconds. Supports BPE, WordPiece, and Unigram algorithms. Train custom vocabularies, track alignments, handle padding/truncation. Integrates seamlessly with transformers. Use when you need high-performance tokenization or custom tokenizer training.
massgen-develops-massgen
massgen
Guide for using MassGen to develop and improve itself. This skill should be used when agents need to run MassGen experiments programmatically (using automation mode) OR analyze terminal UI/UX quality (using visual evaluation tools). These are mutually exclusive workflows for different improvement goals.