MaxFrame coding skill

Updated at:
Copy as MD

An AI-powered programming assistant for distributed data development

Overview

MaxFrame Coding Skill is an AI programming assistant for MaxFrame from Alibaba Cloud. It integrates with mainstream AI programming assistants as an intelligent plugin that injects the complete MaxFrame distributed data processing knowledge system into an AI agent. This enables the AI agent to automatically generate ready-to-run MaxFrame code based on natural language descriptions.

MaxFrame Coding Skill covers the end-to-end development workflow for MaxFrame—from Session management, data I/O, and operator selection to writing results. It lowers the barrier to entry for distributed data processing and improves coding efficiency.

Technical architecture

MaxFrame Coding Skill uses a multi-layered knowledge injection architecture to systematically equip an AI agent with a complete development knowledge system:

┌───────────────────────────────────────────────────┐
│               AI Programming Assistant             │
│    (Claude Code / Cursor / Codex / Gemini CLI /   │
│        Tongyi Lingma / OpenCode / ...)             │
├───────────────────────────────────────────────────┤
│            MaxFrame Coding Skill                  │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐         │
│  │  Coding    │  │  Context   │  │  Operator  │         │
│  │ Skill Def. │  │   Guide    │  │ Selection  │         │
│  └──────────┘  └──────────┘  │    Agent   │         │
│  ┌──────────┐  ┌──────────┐  └──────────┘         │
│  │ Selection  │  │ API Docs   │  ┌──────────┐         │
│  │ Rule Engine│  │ 900+ Pages │  │  Operator  │         │
│  └──────────┘  └──────────┘  │ Validation │         │
│  ┌────────────────────────────────────────┐  │  Scripts   │         │
│  │         Production-Grade Code Examples      │  └──────────┘         │
│  └────────────────────────────────────────┘       │
├───────────────────────────────────────────────────┤
│               MaxFrame SDK                        │
│    DataFrame │ Tensor │ Learn │ UDF │ Session     │
├───────────────────────────────────────────────────┤
│            MaxCompute Distributed Engine          │
└───────────────────────────────────────────────────┘

Component

Description

Coding skill definition

Defines the skill's core responsibilities, capability boundaries, and workflow.

Context guide

A comprehensive 1,700+ line reference document covering all features from basic to advanced.

Operator selection agent

An intelligent agent for operator discovery, validation, and recommendation.

Selection rule engine

Selection strategies based on principles like performance-first, batch-processing-first, and compatibility-first.

API documentation library

A 900+ page library of complete MaxFrame API documentation, available for real-time queries.

Operator validation scripts

Executable scripts to verify an operator's existence and retrieve its detailed documentation.

Production-grade code examples

10 complete, production-grade code templates covering typical scenarios.

Supported platforms

MaxFrame Coding Skill supports all mainstream AI programming assistants with a unified installation method:

AI platform

Installation directory

Claude Code

.claude/skills/

Cursor

.cursor/rules/

Codex

.codex/skills/

OpenCode

.opencode/skills/

Gemini CLI

.gemini/skills/

Tongyi Lingma / Qoder

.aone_copilot/skills/ or .qoder/skills/

Installation

  1. Download the installation package

    Skill installation package: https://skills.aliyun.com/skills/alibabacloud-odps-maxframe-coding

  2. Unzip the package into your AI programming assistant's skills directory (using Claude Code as an example):

    unzip maxframe-coding-skill.zip -d your-project/.claude/skills/

  3. Verify the installation

    ls your-project/.claude/skills/maxframe-job-coding/

    The directory should contain: SKILL.md, examples/, references/, scripts/

  4. After installation, enter the following prompt in your AI programming assistant to test the skill:

    Create a MaxFrame job that reads data from the user_behavior table, groups it by city to calculate GMV, and writes the results to the city_gmv_report table.

    The AI will automatically perform the following steps:

    1. Confirm the data source and output destination.

    2. Recommend the optimal operator combination, such as groupby().agg().

    3. Generate runnable code with complete Session management and error handling.

Core capabilities

Operator recommendation

MaxFrame provides a multi-layered operator system, including standard pandas-compatible operators, MaxFrame-exclusive .mf extension operators (such as apply_chunk, map_reduce, flatmap, and rebalance), and UDF/UDTF capabilities. For any given data processing requirement, the built-in operator selection agent automatically selects and validates operators:

  • Task-driven recommendations: Recommends the optimal operator combination based on the task description and explains the reasoning.

  • API authenticity validation: Validates operator existence in real time against 900+ pages of API documentation to prevent hallucinated APIs.

  • Alternative solutions: Automatically provides alternatives, including a UDF fallback solution, when the primary operator has limitations.

Example:

User: "I need to calculate a rolling average for my time-series data."
AI:   "I recommend using DataFrame.rolling(). 
       If you need custom window logic, you can use .mf.apply_chunk() as a fallback solution."

End-to-end code generation

The Coding Skill covers the entire MaxFrame development lifecycle:

Session creation → Data reading → Operator selection → Data processing → Result writing → Session cleanup

It uses a three-phase, confirm-then-execute interaction model to ensure the generated code precisely matches your requirements:

Phase

Content

Description

Phase 1

Requirement and data confirmation

Confirm data sources, target tables, column selections, and other details.

Phase 2

Operator selection confirmation

Display recommended operators and alternative solutions, and await confirmation.

Phase 3

Code generation and validation

Generate complete, runnable code based on the confirmed information.

All generated code adheres to production-grade standards:

  • Uses a try/finally pattern to ensure Session resources are always cleaned up.

  • Automatically calls .execute() to trigger lazy execution.

  • Correctly declares UDF return types (dtypes).

  • Includes robust error handling logic.

Pitfall avoidance

MaxFrame code generated by general-purpose AIs often encounters the following issues. The Coding Skill addresses each of them with its built-in knowledge base:

Common pitfall

Solution

Calling non-existent APIs

Real-time validation against a 900+ page documentation library prevents hallucinated APIs.

Omitting the .execute() call

Enforces the lazy execution model by including the execution trigger in all code templates.

Failing to destroy the Session

All code uses a try/finally pattern to ensure resource release.

Mismatched UDF return types

Example code demonstrates the correct way to declare dtypes.

Improper execution engine selection

Automatically recommends engines in order of priority: SQL Engine > DPE > SPE.

Using inefficient operators

Automatically recommends DataFrame.mf.apply_chunk instead of Series.apply.

Scenario templates

The Coding Skill includes 10 production-grade code templates covering typical business scenarios. The AI agent can reference these templates to generate high-quality code:

Scenario category

Example file

Core capability

AI large model inference

ai_function_basic.py

Out-of-the-box distributed batch inference with ManagedTextLLM.

GPU-accelerated computing

gpu_unit_dpe_processing.py

GPU resource allocation with @with_running_options(gu=1).

OSS file processing

fs_mount_example.py

Distributed OSS file reading with @with_fs_mount.

Multi-path OSS mounting

oss_multi_mount.py

Simultaneous mounting of single or multiple OSS buckets.

Grouped batch processing

groupby_batch_processing.py

Efficient grouped batch processing with groupby + apply_chunk.

Complex data structures

complex_struct.py

Nested structs and custom group processing.

Arrow type handling

complex_struct_arrow.py

Complex PyArrow types and JSON conversion.

Writing to DLF external tables

dlf_table_write_basic.py

Configuring and writing data to DLF external tables.

Writing to DLF primary key tables

dlf_table_write_with_pk.py

Handling of tables with a primary key and binary data types.

Large-scale document deduplication

minhash_lsh_document_similarity.py

MinHash + LSH algorithm, supporting over 4,000 degrees of parallelism.

Use cases

LLM batch inference

Requirement: Perform batch inference on massive amounts of text data using a large language model.

Example Generated Code:

You do not need to deploy models, manage GPU resources, or write inference services. ManagedTextLLM provides multiple built-in models, such as the qwen2.5 series and DeepSeek-R1, that are available for immediate use.

import maxframe.dataframe as md
from odps import ODPS
from maxframe.learn.contrib.llm.models.managed import ManagedTextLLM
from maxframe.session import new_session
import os

o = ODPS(
    os.getenv('ALIBABA_CLOUD_ACCESS_KEY_ID'),
    os.getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET'),
    project='your-default-project',
    endpoint='your-end-point',
)

# Initialize a MaxFrame Session
session = new_session(o)

try:
  # Read the data for inference
  df = md.DataFrame({
    "query": ["What is the average distance between Earth and the Sun?", "What is the boiling point of water?"]
  })
  df.execute()


  # Perform inference using a managed large language model
  llm = ManagedTextLLM(name="qwen2.5-1.5b-instruct")
  messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "{query}"},
  ]
  result = llm.generate(df, prompt_template=messages)
  result.execute()
finally:
  session.destroy()

OSS file processing

Requirement: Mount files from OSS to each distributed worker node for parallel reading and processing.

Example Generated Code:

The OSS path is automatically mounted as a local file system path. Distributed worker nodes read the data in parallel, allowing throughput to scale linearly with the number of nodes.

from maxframe.udf import with_fs_mount, with_running_options


@with_running_options(engine="dpe", cpu=2, memory=4)
@with_fs_mount(
  "oss://your-bucket/model-files/",
  "/mnt/model",
  storage_options={"role_arn": "acs:ram::xxx:role/xxx"}
)
def read_model_directory(row):
  import os
  files = os.listdir("/mnt/model")
  # Each worker reads independently, enabling automatic distributed parallelism.
  ...