coding-systems
Systems meta-skill: Rust + Nim + Go + C for low-level, memory safety, FFI, performance-critical code
What this skill does
# coding-systems
## Purpose
This skill equips the AI to handle systems programming using Rust, Nim, Go, and C, focusing on low-level operations, memory safety, FFI (Foreign Function Interface), and performance-critical code. It combines these languages for tasks like OS development, embedded systems, and high-throughput applications.
## When to Use
Use this skill for scenarios requiring direct hardware access, memory management, or inter-language calls, such as writing kernel modules, optimizing network servers, or integrating C libraries into modern languages. Avoid for high-level web apps; prefer when performance bottlenecks demand low-level control.
## Key Capabilities
- **Rust**: Enforces memory safety via ownership and borrowing; supports FFI with C using `extern "C"` blocks.
- **Nim**: Offers metaprogramming and FFI via `importc` pragma; compiles to C for performance.
- **Go**: Provides concurrency with goroutines and channels; uses cgo for FFI to C libraries.
- **C**: Enables raw memory manipulation and OS interactions; use for performance-critical kernels.
- Specific features: Rust's `unsafe` blocks for pointer arithmetic; Go's `sync` package for thread-safe operations; Nim's templates for code generation; C's `mmap` for direct memory mapping.
## Usage Patterns
To accomplish tasks, structure code with language-specific patterns: Use Rust for safe wrappers around C code; employ Go for scalable concurrent systems; leverage Nim for rapid prototyping of C-like code; fall back to C for hardware-level optimizations. For FFI, always define interfaces first (e.g., in C headers), then bind in target languages. Pattern: Import C headers in Rust via `#[link(name = "libc")]`; in Go, use `// #cgo LDFLAGS: -lmylib` for linking.
## Common Commands/API
- **Rust**: Build with `cargo build --release` for optimized binaries; use `std::ffi::c_void` for FFI pointers. API example: `extern "C" fn add(a: i32, b: i32) -> i32 { a + b }`
- **Nim**: Compile with `nim c --cc:gcc -d:release myfile.nim`; FFI via `proc add(a: cint, b: cint): cint {.importc: "add", header: "myheader.h".}`
- **Nim code snippet**:
```nim
proc add(a: cint, b: cint): cint {.importc.}
echo add(1, 2) # Calls external C function
```
- **Go**: Run `go build -o myapp` with cgo; API: `import "C"` for FFI. Example: `C.add(C.int(1), C.int(2))`
- **Go code snippet**:
```go
import "C"
func main() { println(int(C.add(1, 2))) }
```
- **C**: Compile with `gcc -O3 -o myprog myfile.c` for optimizations; use `#include <sys/mman.h>` for OS APIs.
- Config formats: Use Cargo.toml for Rust dependencies (e.g., `[dependencies] libc = "0.2"`); Go's go.mod for modules; Nim's .nimble for packages.
## Integration Notes
Integrate by linking languages via FFI: For Rust-C, set `build.rs` to generate bindings with bindgen; in Go, use cgo directives like `// #include "myheader.h"`. If API keys are needed (e.g., for external tools), set env vars like `$RUST_ANALYZER_API_KEY`. For cross-language projects, use CMake for unified builds: Add `add_subdirectory(rust_project)` in CMakeLists.txt. Always handle ABI compatibility; e.g., ensure C functions use `__attribute__((visibility("default")))` for export.
## Error Handling
In Rust, use `Result<T, E>` for fallible operations; check with `match` or `?`. For Nim, use exceptions with `try/except`; e.g., `try: raise newException(ValueError, "Error") except: echo "Handled"`. Go errors return as second values; check with `if err != nil { return err }`. C uses errno; wrap with custom error codes. General pattern: Propagate errors up the call stack and log with details, e.g., in Rust: `fn safe_add(a: i32) -> Result<i32, String> { if a < 0 { Err("Negative input".to_string()) } else { Ok(a + 1) } }`.
## Concrete Usage Examples
1. **FFI Wrapper for C Library in Rust**: To call a C function for memory allocation, first define the interface: Use `extern "C" { fn malloc(size: usize) -> *mut u8; }`. Then, in code: `let ptr = unsafe { malloc(1024) }; if ptr.is_null() { panic!("Allocation failed"); }`. This pattern ensures safe memory handling in performance-critical apps.
2. **Concurrent Performance Task in Go**: For a high-throughput server, use goroutines: `go func() { for i := 0; i < 100; i++ { fmt.Println(i) } }(); runtime.Gosched()`. Integrate with C via cgo for low-level I/O, e.g., to read from a file descriptor, ensuring non-blocking operations for real-time systems.
## Graph Relationships
- Cluster: Related to "coding" cluster for general programming skills.
- Tags: Connected via "systems", "low-level", "performance", "coding" to other skills like "ffi-handling" or "memory-management".
- Embedding: Links to skills with similar vectors, such as "os-programming" based on "systems programming low level memory performance ffi os c rust nim go".
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.