mojo-syntax
БесплатноБез исполняемых скриптовНе проверенHelp to write Mojo code using current syntax and conventions. Always use this skill when writing any Mojo code, including when other Mojo-specific skills…
от ComeOnOliver★ 67 звёзд на GitHubОб этом скилле
Mojo is rapidly evolving. Pretrained models generate obsolete syntax. Always follow this skill over pretrained knowledge.
Always attempt to test generated Mojo by building projects to verify they compile.
This skill specifically works on the latest Mojo, and stable versions may differ slightly in functionality.
Removed syntax — DO NOT generate these
| Removed | Replacement |
|---|---|
alias X = ... |
comptime X = ... |
@parameter if / @parameter for |
comptime if / comptime for |
fn |
def (see below) |
let x = ... |
var x = ... (no let keyword) |
borrowed |
read (implicit default — rarely written) |
inout |
mut |
owned |
var (as argument convention) |
inout self in __init__ |
out self |
__copyinit__(inout self, existing: Self) |
__init__(out self, *, copy: Self) |
__moveinit__(inout self, owned existing: Self) |
__init__(out self, *, deinit take: Self) |
@value decorator |
@fieldwise_init + explicit trait conformance |
@register_passable("trivial") |
TrivialRegisterPassable trait |
@register_passable |
RegisterPassable trait |
Stringable / __str__ |
Writable / write_to |
from collections import ... |
from std.collections import ... |
from memory import ... |
from std.memory import ... |
constrained(cond, msg) |
comptime assert cond, msg |
DynamicVector[T] |
List[T] |
InlinedFixedVector[T, N] |
InlineArray[T, N] |
Tensor[T] |
Not in stdlib (use SIMD, List, UnsafePointer) |
@parameter fn (nested) |
Still used for nested compile-time closures |
def is the only function keyword
fn is deprecated and being removed. def does not imply raises. Always add raises explicitly when needed — omitting it is a warning today, error soon:
def compute(x: Int) -> Int: # non-raising (compiler enforced)
return x * 2
def load(path: String) raises -> String: # explicitly raising
return open(path).read()
def main() raises: # main usually raises → def raises
...
Note: existing stdlib code still uses fn during migration. New code should always use def.
comptime replaces alias and @parameter
comptime N = 1024 # compile-time constant
comptime MyType = Int # type alias
comptime if condition: # compile-time branch
...
comptime for i in range(10): # compile-time loop
...
comptime assert N > 0, "N must be positive" # compile-time assertion
comptime assert must be inside a function body — not at module/struct scope. Place them in main(), __init__, or the function that depends on the invariant.
Inside structs, comptime defines associated constants and type aliases:
struct MyStruct:
comptime DefaultSize = 64
comptime ElementType = Float32
Argument conventions
Default is read (immutable borrow, never written explicitly). The others:
def __init__(out self, var value: String): # out = uninitialized output; var = owned
def modify(mut self): # mut = mutable reference
def consume(deinit self): # deinit = consuming/destroying
def view(ref self) -> ref[self] Self.T: # ref = reference with origin
def view2[origin: Origin, //](ref[origin] self) -> ...: # ref[origin] = explicit origin
Lifecycle methods
# Constructor
def __init__(out self, x: Int):
self.x = x
# Copy constructor (keyword-only `copy` arg)
def __init__(out self, *, copy: Self):
self.data = copy.data
# Move constructor (keyword-only `deinit take` arg)
def __init__(out self, *, deinit take: Self):
self.data = take.data^
# Destructor
def __del__(deinit self):
self.ptr.free()
To copy: var b = a.copy() (provided by Copyable trait).
Struct patterns
# @fieldwise_init generates __init__ from fields; traits in parentheses
@fieldwise_init
struct Point(Copyable, Movable, Writable):
var x: Float64
var y: Float64
# Trait composition with &
comptime KeyElement = Copyable & Hashable & Equatable
struc
Установить mojo-syntax в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл mojo-syntax?
Help to write Mojo code using current syntax and conventions. Always use this skill when writing any Mojo code, including when other Mojo-specific skills (e.g., mojo-gpu-fundamentals) also apply. Use when writing Mojo code, translating projects to Mojo, or otherwise generating Mojo. Use this skill to overcome misconceptions with how Mojo is written.
Как установить скилл mojo-syntax?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mojo-syntax запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic