TVM FFI Development

VerifiedCaution

This skill assists in developing and verifying Foreign Function Interface (FFI) changes in TVM. It can take a GitHub issue URL or a text description, then fetches details, writes a minimal Python reproducer, and follows a development loop with building and testing. It enforces project-specific code style and best practices for C++ and Python.

Sby Skills Guide Bot
DevelopmentIntermediate
806/2/2026
Claude Code
#tvm#ffi#development#verification#cpp-python

Recommended for

Our review

This skill helps develop and verify TVM Foreign Function Interface (FFI) changes.

Strengths

  • Provides a complete workflow: understanding, implementation, build, and test.
  • Enforces strict code style guidelines for C++ and Python, improving code quality.
  • Automates reproducibility by writing and running repro scripts.
  • Simplifies GitHub issue handling via a dedicated command.

Limitations

  • Requires prior knowledge of TVM and its FFI internals.
  • Depends on the TVM build and test environment (/tvm-ffi-build, /tvm-ffi-test).
  • May not cover all edge cases not described in the instructions.
When to use it

Use this skill when implementing or fixing TVM FFI functionality, from bug reproduction to validation.

When not to use it

Avoid this skill for generic TVM development tasks not involving FFI, or if you are unfamiliar with the specified coding conventions.

Security analysis

Caution
Quality score85/100

The skill involves executing Python scripts and build/test commands, which could potentially run malicious code if given untrusted issue descriptions. The operations are legitimate for development but are powerful, warranting caution.

Findings
  • Runs Python repro scripts and build/test commands, which could execute arbitrary code. This is typical for a development workflow but requires caution.

Examples

Fix a TVM FFI bug from GitHub issue
/tvm-ffi-dev https://github.com/apache/tvm/issues/12345
Implement a new FFI feature
/tvm-ffi-dev Add a new FFI function to access tensor data via std::expected
Continue current FFI work
/tvm-ffi-dev

name: tvm-ffi-dev description: Develop and verify TVM FFI changes.

TVM FFI Dev

Usage

/tvm-ffi-dev                  # auto-run: pick next item or continue current work
/tvm-ffi-dev <GitHub issue URL>
/tvm-ffi-dev <text description>

Instructions

  1. Understand the task:

    • If given a GitHub issue URL, fetch with gh issue view <URL>
    • Write a minimal Python repro script and run it to confirm the error. If it can't be reproduced, stop and report.
    • If given text, use that as the requirement
  2. Follow /dev-autodev loop with these project-specific details:

    • If fixing an issue: Re-run the repro script to verify it passes, then delete it.
    • Verify: Use /tvm-ffi-build, then /tvm-ffi-test.

Code style

  • C++: prefer std::string_view, static_cast, STL algorithms over manual loops
  • C++: add move-qualified overloads (&&) for accessors returning owned values
  • C++: align new APIs with C++ std equivalents (e.g. std::expected, std::unexpected), list deviations explicitly
  • C++: use std::move on optionals (*std::move(val)), avoid double checking
  • C++: fast path first (value before error), minimize branches
  • C++: ban implicit conversions for error types, use explicit constructors (e.g. Unexpected(Error(...)))
  • Python: reuse stdlib types (e.g. dataclasses.KW_ONLY) instead of redefining
  • Tests: call actual registered FFI functions, not reimplement logic
  • Tests: use ASSERT_TRUE for null checks before dereferencing
  • Tests: no duplicate assertions, remove redundant checks
  • Extract duplicated logic into helpers
  • New user-facing APIs need documentation with usage examples
  • Preserve original error info on rethrow, not generic messages
Related skills