CSnakes
Embed Python in .NET
Install / Use
/learn @tonybaloney/CSnakesREADME
CSnakes - a tool for embedding Python code into .NET projects
<img src="docs/res/logo.jpeg" alt="drawing" width="200"/>CSnakes is a .NET Source Generator and Runtime that you can use to embed Python code and libraries into your C#.NET Solution at a performant, low-level without the need for REST, HTTP, or Microservices.
Check out the getting started guide or check out the demo solution to see more.
Features
- 🤖 Supports .NET 8 and 9
- 🐍 Supports Python 3.9-3.13
- 📦 Supports Virtual Environments and C-Extensions
- 💻 Supports Windows, macOS, and Linux
- 🧮 Tight integration between NumPy ndarrays and Spans, 2D Spans and TensorSpans (.NET 9)
- ⚡ Uses Python's C-API for fast invocation of Python code directly in the .NET process
- 🧠 Uses Python type hinting to generate function signatures with .NET native types
- 🧵 Supports CPython 3.13 "free-threading" mode
- 🧩 Supports nested sequence and mapping types (
tuple,dict,list) - 🏷️ Supports default values
- 🔥 Supports Hot Reload of Python code in Visual Studio and supported IDEs
- 🚀 Supports UV for fast installation of Python packages and dependencies
Benefits
- Uses native Python type hinting standards to produce clean, readable C# code with minimal boiler plate!
- Integration between .NET and Python is done at the C-API, meaning strong compatibility between Python versions 3.8-3.13 and .NET 8-9.
- Integration is low-level and high-performance.
- CSnakes uses the CPython C-API and is compatible with all Python extensions.
- Invocation of Python code and libraries is in the same process as .NET
Click to watch the CSnakes demo video on YouTube
<br />Example
CSnakes will generate a C#.NET class for any Python file in a project that is tagged as CSharp Analyzer Additional File (see Getting Started). All functions in that class with type annotations will be reflected to callable C# methods and an environment builder added to that module.

Given the following Python file called example.py
def hello_world(name: str, age: int) -> str:
return f"Hello {name}, you must be {age} years old!"
CSnakes will generate a static .NET class called Example with the function:
public class Example {
public static string HelloWorld(string name, long age) {
...
}
}
When called, HelloWorld() will invoke the Python function from example.py using Python's C-API and return native .NET types.
FAQ
See the FAQ for more information.
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
107.2kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
346.4kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.

