Agent skill

Mlir Development

by aftermathlabs in aftermathlabs/llvm-msvc

Expertise in MLIR (Multi-Level Intermediate Representation) and CIR (Clang IR) development for domain-specific compilation and high-level optimizations.

AGPL-3.0Auto-check passedAI & LLM Engineering

Install Mlir Development

skills CLI
$ npx skills add aftermathlabs/llvm-msvc --skill mlir-development -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install aftermathlabs/llvm-msvc mlir-development --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/aftermathlabs/llvm-msvc.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/mlir-development .claude/skills/mlir-development && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
mlir-development
GitHub stars
438
Token cost
~2.4k tokens
SKILL.md length
283 words
Files
1
Skills in repo
8
Repo updated
First seen
Licence
AGPL-3.0

At a glance

Expertise in MLIR (Multi-Level Intermediate Representation) and CIR (Clang IR) development for domain-specific compilation and high-level optimizations.

  • Works in 5 steps: Progressive Lowering: Lower in multiple… → Preserve Semantics: Each lowering should… → Use ODS: Define operations in TableGen… → …
  • Building ML compilers
  • SKILL.md covers MLIR Overview, Core Concepts, Writing MLIR Passes and Dialect Conversion, plus 5 more sections
  • Reaches raw.githubusercontent.com

What it does

Mlir Development is an agent skill from aftermathlabs/llvm-msvc. Expertise in MLIR (Multi-Level Intermediate Representation) and CIR (Clang IR) development for domain-specific compilation and high-level optimizations. Use this skill when building ML compilers, domain-specific languages, or working with multi-level compilation pipelines.

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering Deep learning. The repository describes itself as: LLVM fork with explicit compatibility with MSVC 2022 features. The licence is AGPL-3.0.

When your agent uses it

  • Building ML compilers
  • Domain-specific languages
  • Working with multi-level compilation pipelines

Example prompts

  • “/mlir-development”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Progressive Lowering: Lower in multiple stages, not directly to LLVM
  2. Preserve Semantics: Each lowering should be semantics-preserving
  3. Use ODS: Define operations in TableGen for consistency
  4. Test Thoroughly: Use FileCheck for transformation tests
  5. Document Dialects: Clear operation semantics documentation

What it can do on your machine

Read from SKILL.md and the folder at commit bfc7254. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are cpp, mlir and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • raw.githubusercontent.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Mlir Development loads about 2.4k tokens when it runs. Until then it costs about 73 tokens; SKILL.md has 283 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~73
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from aftermathlabs/llvm-msvc at commit bfc7254, republished under its AGPL-3.0 licence (© aftermathlabs). 283 words, ~2,390 tokens.

Download SKILL.mdSave it as .claude/skills/mlir-development/SKILL.md (or your agent's skills folder).
name
mlir-development
description
Expertise in MLIR (Multi-Level Intermediate Representation) and CIR (Clang IR) development for domain-specific compilation and high-level optimizations. Use this skill when building ML compilers, domain-specific languages, or working with multi-level compilation pipelines.

MLIR Development Skill

This skill covers MLIR (Multi-Level Intermediate Representation) development for building domain-specific compilers and high-level optimization pipelines.

MLIR Overview

What is MLIR?

MLIR is a compiler infrastructure that enables building reusable and extensible compiler components. It provides:

  • Hierarchical, multi-level IR representation
  • Extensible operation and type system
  • Progressive lowering between abstraction levels
  • Rich transformation infrastructure
Architecture
High-Level DSL
     ↓
Domain-Specific Dialects (e.g., TensorFlow, PyTorch)
     ↓
Mid-Level Dialects (e.g., Linalg, Affine)
     ↓
Low-Level Dialects (e.g., LLVM, GPU)
     ↓
Target Code

Core Concepts

Dialects

Dialects are groupings of operations, types, and attributes:

cpp
// Define a custom dialect
class MyDialect : public mlir::Dialect {
public:
    explicit MyDialect(mlir::MLIRContext *context)
        : Dialect("my_dialect", context, 
                  mlir::TypeID::get<MyDialect>()) {
        addOperations<
            MyAddOp,
            MyMulOp,
            MyFuncOp
        >();
        addTypes<MyTensorType>();
    }
    
    static llvm::StringRef getDialectNamespace() { 
        return "my_dialect"; 
    }
};
Operations
cpp
// Define using ODS (Operation Definition Specification)
// In TableGen file (.td)
def MyAddOp : Op<MyDialect, "add", [Pure]> {
    let summary = "Add two tensors";
    let description = [{
        Performs element-wise addition of two tensors.
    }];
    
    let arguments = (ins 
        AnyTensor:$lhs,
        AnyTensor:$rhs
    );
    
    let results = (outs 
        AnyTensor:$result
    );
    
    let assemblyFormat = [{
        $lhs `,` $rhs attr-dict `:` type($result)
    }];
}
Types and Attributes
cpp
// Custom type definition
class MyTensorType : public mlir::Type::TypeBase<
    MyTensorType, mlir::Type, MyTensorTypeStorage> {
public:
    using Base::Base;
    
    static MyTensorType get(mlir::MLIRContext *context,
                            llvm::ArrayRef<int64_t> shape,
                            mlir::Type elementType) {
        return Base::get(context, shape, elementType);
    }
    
    llvm::ArrayRef<int64_t> getShape() const;
    mlir::Type getElementType() const;
};

Writing MLIR Passes

Transform Pass
cpp
#include "mlir/Pass/Pass.h"
#include "mlir/IR/PatternMatch.h"

struct MyOptimizationPass
    : public mlir::PassWrapper<MyOptimizationPass,
                                mlir::OperationPass<mlir::func::FuncOp>> {
    
    void runOnOperation() override {
        mlir::func::FuncOp func = getOperation();
        
        // Walk all operations
        func.walk([](mlir::Operation *op) {
            // Transform operations
            if (auto addOp = llvm::dyn_cast<MyAddOp>(op)) {
                optimizeAdd(addOp);
            }
        });
    }
    
    llvm::StringRef getArgument() const final { 
        return "my-optimization"; 
    }
    
    llvm::StringRef getDescription() const final {
        return "My custom optimization pass";
    }
};
Pattern-Based Rewriting
cpp
// Define rewrite pattern
struct SimplifyRedundantAdd : public mlir::OpRewritePattern<MyAddOp> {
    using OpRewritePattern<MyAddOp>::OpRewritePattern;
    
    mlir::LogicalResult matchAndRewrite(
        MyAddOp op,
        mlir::PatternRewriter &rewriter) const override {
        
        // Match: add(x, 0) -> x
        if (auto constOp = op.getRhs().getDefiningOp<ConstantOp>()) {
            if (isZero(constOp)) {
                rewriter.replaceOp(op, op.getLhs());
                return mlir::success();
            }
        }
        return mlir::failure();
    }
};

// Apply patterns
void runOnOperation() override {
    mlir::RewritePatternSet patterns(&getContext());
    patterns.add<SimplifyRedundantAdd>(&getContext());
    
    if (mlir::failed(mlir::applyPatternsAndFoldGreedily(
            getOperation(), std::move(patterns)))) {
        signalPassFailure();
    }
}

Dialect Conversion

Lowering Between Dialects
cpp
// Convert high-level ops to lower-level ops
struct MyAddOpLowering : public mlir::OpConversionPattern<MyAddOp> {
    using OpConversionPattern<MyAddOp>::OpConversionPattern;
    
    mlir::LogicalResult matchAndRewrite(
        MyAddOp op,
        OpAdaptor adaptor,
        mlir::ConversionPatternRewriter &rewriter) const override {
        
        // Lower to arith dialect
        rewriter.replaceOpWithNewOp<mlir::arith::AddFOp>(
            op, adaptor.getLhs(), adaptor.getRhs());
        return mlir::success();
    }
};

// Conversion pass
struct LowerToArithPass : public mlir::PassWrapper<
    LowerToArithPass, 
    mlir::OperationPass<mlir::ModuleOp>> {
    
    void runOnOperation() override {
        mlir::ConversionTarget target(getContext());
        target.addLegalDialect<mlir::arith::ArithDialect>();
        target.addIllegalDialect<MyDialect>();
        
        mlir::RewritePatternSet patterns(&getContext());
        patterns.add<MyAddOpLowering>(&getContext());
        
        if (mlir::failed(mlir::applyPartialConversion(
                getOperation(), target, std::move(patterns)))) {
            signalPassFailure();
        }
    }
};

Built-in Dialects

Affine Dialect

For polyhedral compilation and loop optimizations:

mlir
affine.for %i = 0 to 100 {
    affine.for %j = 0 to 100 {
        %val = affine.load %A[%i, %j] : memref<100x100xf32>
        affine.store %val, %B[%j, %i] : memref<100x100xf32>
    }
}
Linalg Dialect

For linear algebra operations:

mlir
linalg.matmul ins(%A, %B : tensor<MxKxf32>, tensor<KxNxf32>)
              outs(%C : tensor<MxNxf32>) -> tensor<MxNxf32>
SCF Dialect (Structured Control Flow)
mlir
%result = scf.for %i = %lb to %ub step %step iter_args(%sum = %init) {
    %val = memref.load %A[%i] : memref<?xf32>
    %new_sum = arith.addf %sum, %val : f32
    scf.yield %new_sum : f32
}

CIR (Clang IR)

Overview

CIR is an MLIR-based representation for C/C++, providing:

  • Higher-level representation than LLVM IR
  • Better debugging and tooling
  • Language-specific optimizations
mlir
// CIR example
cir.func @add(%a: !s32i, %b: !s32i) -> !s32i {
    %result = cir.binop(add, %a, %b) : !s32i
    cir.return %result : !s32i
}
CIR Projects
  • llvm/clangir: Official ClangIR implementation
  • facebookincubator/clangir: Facebook's CIR experiments

ML/AI Compilation

TensorFlow MLIR
mlir
// TensorFlow dialect
%result = "tf.MatMul"(%A, %B) {
    transpose_a = false,
    transpose_b = false
} : (tensor<4x8xf32>, tensor<8x16xf32>) -> tensor<4x16xf32>
PyTorch MLIR (torch-mlir)
mlir
// Torch dialect
%result = torch.aten.mm %A, %B : 
    !torch.vtensor<[4,8],f32>, !torch.vtensor<[8,16],f32> 
    -> !torch.vtensor<[4,16],f32>
IREE (Intermediate Representation Execution Environment)

End-to-end MLIR compiler for ML models:

  • Portable deployment
  • Efficient runtime execution
  • Multi-target support (CPU, GPU, TPU)

Testing MLIR

FileCheck Tests
mlir
// RUN: mlir-opt %s -my-pass | FileCheck %s

// CHECK-LABEL: func @test_optimization
// CHECK: arith.addi
// CHECK-NOT: my_dialect.add
func @test_optimization(%a: i32, %b: i32) -> i32 {
    %result = my_dialect.add %a, %b : i32
    return %result : i32
}
Unit Testing
cpp
TEST(MyDialect, AddOpConstantFolding) {
    mlir::MLIRContext context;
    context.loadDialect<MyDialect>();
    
    mlir::OpBuilder builder(&context);
    auto loc = builder.getUnknownLoc();
    
    // Create and test operations
    auto constA = builder.create<ConstantOp>(loc, 5);
    auto constB = builder.create<ConstantOp>(loc, 3);
    auto add = builder.create<MyAddOp>(loc, constA, constB);
    
    // Verify folding
    EXPECT_TRUE(add.fold().succeeded());
}

Development Tools

mlir-opt
bash
# Run passes
mlir-opt input.mlir -my-pass -o output.mlir

# Convert between dialects
mlir-opt input.mlir -convert-my-to-llvm

# Debug printing
mlir-opt input.mlir -debug-only=my-pass
mlir-translate
bash
# MLIR to LLVM IR
mlir-translate input.mlir --mlir-to-llvmir -o output.ll

# LLVM IR to MLIR
mlir-translate input.ll --import-llvm -o output.mlir

Best Practices

  1. Progressive Lowering: Lower in multiple stages, not directly to LLVM
  2. Preserve Semantics: Each lowering should be semantics-preserving
  3. Use ODS: Define operations in TableGen for consistency
  4. Test Thoroughly: Use FileCheck for transformation tests
  5. Document Dialects: Clear operation semantics documentation

Resources

See MLIR and CIR sections in README.md for tutorials and example projects.

Getting Detailed Information

When you need detailed and up-to-date resource links, tool lists, or project references, fetch the latest data from:

https://raw.githubusercontent.com/gmh5225/awesome-llvm-security/refs/heads/main/README.md

This README contains comprehensive curated lists of:

  • MLIR tutorials and sample dialects (MLIR section)
  • CIR (Clang IR) projects and documentation (CIR section)
  • ML/AI compiler frameworks (torch-mlir, IREE, XLA)

© aftermathlabs, AGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/mlir-development of aftermathlabs/llvm-msvc.

Open the folder on GitHubat commit bfc7254

Compare with similar skills

Mlir Development next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Mlir Development compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mlir Development this skillaftermathlabs/llvm-msvc438—~2.4kAutomated safety check: PassAGPL-3.0
Add Uint Supportpytorch/pytorch104k2 repos~2.3kAutomated safety check: PassCustom licence
Segment Anything Model GuideOrchestra-Research/AI-Research-SKILLs13k9 repos~3.3kAutomated safety check: PassMIT
Add Oponnx/onnx22k—~1.2kAutomated safety check: PassApache-2.0
CLIP Image-Text MatchingOrchestra-Research/AI-Research-SKILLs13k8 repos~1.7kAutomated safety check: PassMIT
Add Function Bodyonnx/onnx22k—~1.1kAutomated safety check: PassApache-2.0

Similar skills

  • Add Uint Support

    pytorch/pytorch

    Add unsigned integer (uint) type support to PyTorch operators by updating ATDISPATCH macros.

    104k GitHub starsUsed in 2 repos~2.3k tokens
    AI & LLM EngineeringAuto-check passed
  • Segment Anything Model Guide

    Orchestra-Research/AI-Research-SKILLs

    Guide to using Meta's Segment Anything Model for zero-shot image segmentation with point, box or mask prompts, or automatic mask generation.

    13k GitHub starsUsed in 9 repos~3.3k tokens
    AI & LLM EngineeringAuto-check passed
  • Add Op

    onnx/onnx

    Add a new ONNX operator or update an existing operator to a new opset version.

    22k GitHub stars~1.2k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • CLIP Image-Text Matching

    Orchestra-Research/AI-Research-SKILLs

    Explains OpenAI's CLIP model for zero-shot image classification, image-text similarity, semantic image search and content moderation, with install steps and code patterns.

    13k GitHub starsUsed in 8 repos~1.7k tokens
    AI & LLM EngineeringAuto-check passed
  • Add a function body definition to an ONNX operator, defining how it decomposes into simpler ops.

    22k GitHub stars~1.1k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Paddle Design Distributed

    PaddlePaddle/Paddle

    A skill your agent uses when working with Paddle's distributed training system: understanding parallelism strategies (DP, ZeRO, TP, PP, SP), semi-automatic parallel with ProcessMesh + shardtensor…

    24k GitHub stars~660 tokensUpdated 7 days ago
    AI & LLM EngineeringAuto-check passed

More from aftermathlabs/llvm-msvc

All 8 skills in this repo
  • Compiler Development

    aftermathlabs/llvm-msvc

    Expertise in compiler development using LLVM infrastructure including frontend design, IR generation, optimization passes, and code generation.

    438 GitHub stars~1.7k tokensUpdated 4 days ago
    Auto-check passed
  • Dynamic Instrumentation

    aftermathlabs/llvm-msvc

    Expertise in LLVM-based dynamic binary instrumentation, runtime tracing, and program monitoring.

    438 GitHub stars~2.6k tokensUpdated 4 days ago
    Auto-check passed
  • Llvm Learning

    aftermathlabs/llvm-msvc

    Comprehensive learning resources and tutorials for LLVM, Clang, and compiler development.

    438 GitHub stars~2.1k tokensUpdated 4 days ago
    Auto-check passed
  • Llvm Optimization

    aftermathlabs/llvm-msvc

    Expertise in LLVM optimization passes, performance tuning, and code transformation techniques.

    438 GitHub stars~2.5k tokensUpdated 4 days ago
    Auto-check passed
  • Llvm Security

    aftermathlabs/llvm-msvc

    Expertise in LLVM security features including sanitizers, hardening techniques, exploit mitigations, and secure compilation.

    438 GitHub stars~1.8k tokensUpdated 4 days ago
    Auto-check passed
  • Llvm Tooling

    aftermathlabs/llvm-msvc

    Expertise in LLVM tooling development including Clang plugins, LLDB debugger extensions, Clangd/LSP, and LibTooling.

    438 GitHub stars~2.2k tokensUpdated 4 days ago
    Auto-check passed

Questions about Mlir Development

What does Mlir Development do?

Expertise in MLIR (Multi-Level Intermediate Representation) and CIR (Clang IR) development for domain-specific compilation and high-level optimizations. Mlir Development is an agent skill from aftermathlabs/llvm-msvc. Expertise in MLIR (Multi-Level Intermediate Representation) and CIR (Clang IR) development for domain-specific compilation and high-level optimizations.

When should I use Mlir Development?

Mlir Development fits situations like: building ML compilers; domain-specific languages; working with multi-level compilation pipelines.

How do I install Mlir Development in Claude Code?

Run `npx skills add aftermathlabs/llvm-msvc --skill mlir-development -a claude-code`. Or copy the skill folder (.agents/skills/mlir-development in aftermathlabs/llvm-msvc) into .claude/skills/mlir-development in your project. Claude Code loads it when a task matches its description.

How do I install Mlir Development in Codex?

Run `npx skills add aftermathlabs/llvm-msvc --skill mlir-development -a codex`. Or copy the skill folder (.agents/skills/mlir-development in aftermathlabs/llvm-msvc) into .agents/skills/mlir-development in your project. Codex loads it when a task matches its description.

Can I use Mlir Development in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add aftermathlabs/llvm-msvc --skill mlir-development -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mlir-development, .gemini/skills/mlir-development, .github/skills/mlir-development and .opencode/skills/mlir-development in your project.

What does Mlir Development need to run?

SKILL.md names no scripts, command-line tools or credentials: Mlir Development is instructions for the agent only.

Does Mlir Development access the network?

SKILL.md names 1 domain. In commands or code: raw.githubusercontent.com; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Mlir Development safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Mlir Development use?

Mlir Development is published under the AGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Mlir Development use?

About 2.4k tokens (SKILL.md is roughly 9.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Mlir Development?

Skills that share tags, products or a category with Mlir Development: Add Uint Support (pytorch/pytorch, 104k stars), Segment Anything Model Guide (Orchestra-Research/AI-Research-SKILLs, 13k stars), Add Op (onnx/onnx, 22k stars) and CLIP Image-Text Matching (Orchestra-Research/AI-Research-SKILLs, 13k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Mlir Development?

aftermathlabs (a GitHub organization) maintains it in aftermathlabs/llvm-msvc, which has 438 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on October 3, 2026.

Source: aftermathlabs/llvm-msvc on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.