mojo-syntax

Correct obsolete Mojo syntax and align code with current language conventions.

Updated Apr 15, 2025
One-click install
npx skills add https://github.com/khrore/nix-config --skill mojo-syntax-khrore
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mojo-syntax
Source: https://github.com/khrore/nix-config/tree/main/dotfiles/common/.codex/skills/mojo-syntax
Command: npx skills add https://github.com/khrore/nix-config --skill mojo-syntax-khrore

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pretrained models and outdated examples generate obsolete Mojo syntax and incorrect idioms that lead to compile errors and subtle runtime bugs. This Skill provides a concise, up-to-date correction layer of syntax rules and conventions so generated or refactored Mojo is compile-ready and idiomatic.

Core Features & Use Cases

  • Removed syntax mapping: lists canonical replacements such as alias → comptime, fn → def, let → var, inout → mut, and Stringable → Writable.
  • Language conventions: enforces comptime usage, explicit raises annotations, std.-prefixed imports, Self-qualified struct parameters, correct string indexing and collection literal usage, and ownership/memory patterns.
  • Practical use cases: update generated Mojo code to compile, translate projects from older Mojo variants or Python-like examples, and audit constructors, iterator protocols, and origin/memory annotations.

Quick Start

Convert my Mojo file to current syntax, replacing deprecated constructs, fixing imports and string indexing, and return a compile-ready version that follows the latest Mojo conventions.

Frequently Asked Questions about mojo-syntax

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix obsolete Mojo syntax in generated code to make it compile?

Update obsolete Mojo syntax by replacing deprecated constructs such as fn with def, let with var, and alias with comptime, ensuring generated code aligns with current language conventions and compiles successfully.

What are the current Mojo language conventions for imports and structs?

Current Mojo conventions require std.-prefixed imports, Self-qualified type parameters in structs, explicit raises annotations on functions, and comptime for compile-time aliases and loops to ensure idiomatic code generation.

How do I refactor old Mojo code to use correct memory and iterator patterns?

Refactor old Mojo code by updating ownership and memory patterns, replacing inout with mut, correcting string indexing and collection literal usage, and auditing iterator protocols to match current language standards.

Does this approach work for translating Python-like examples to current Mojo?

Yes, translating Python-like examples to current Mojo works by applying specific syntax corrections, enforcing def for functions, mapping Stringable to Writable, and aligning constructors and memory annotations.

Why does my generated Mojo code fail to compile after syntax updates?

Generated Mojo code fails to compile if compile-time asserts are not placed inside functions, imports lack std. prefixes, or obsolete constructs like alias and fn are used instead of comptime and def.