Skip to content
Prompt

Rtinycc — Copilot Instructions

by sounkou-bioinfo

AI Summary

Rtinycc Copilot Instructions guide AI agents on contributing to the Rtinycc project, which enables C scripting in R through TinyCC compilation. Developers working on this R FFI package benefit from clear conventions for code changes, testing, and leveraging the project's internal reference libraries.

Install

Copy this and paste it into Claude Code, Cursor, or any AI assistant:

I want to add the "Rtinycc — Copilot Instructions" prompt rules to my project.
Repository: https://github.com/sounkou-bioinfo/Rtinycc

Please read the repo to find the rules/prompt file, then:
1. Download it to the correct location (.cursorrules, .windsurfrules, .github/prompts/, or project root — based on the file type)
2. If there's an existing rules file, merge the new rules in rather than overwriting
3. Confirm what was added

Description

Builds 'TinyCC' 'Cli' and Library for 'C' Scripting in 'R'

Rtinycc Agent Guidelines (Short)

This file is the minimum guidance for agentic work on Rtinycc. Read relevant code before changes, keep edits small and focused, and update tests/docs when you change behavior. Agents must read actual implementations before guessing. If you need third-party code or headers, check the .sync directory for local copies of libraries we depend on so you can read them directly instead of assuming behavior. We also generate <package>.llm.txt files for R package docs; for example, treesitter.c docs can be found in treesitter.c.llm.txt. The .sync directory also contains reference implementations that inform the tcc_quick compiler design: codetools (walker/handler), quickr (handler registry, scope tracking), spy (typed C AST, codegen), and Stdlib (the SaC standard library from the SacBase project — array primitives, reductions, transforms, and with-loop patterns that inform our condensation/ψ-reduction architecture).

What this package does

Rtinycc embeds TinyCC and exposes both CLI and libtcc APIs to R. It provides a Bun-style FFI that generates SEXP wrappers at runtime, compiles them with TinyCC, and calls them via .Call.

FFI provenance (critical)

tcc_get_symbol() calls RC_libtcc_get_symbol(), which converts the raw void* from TinyCC into a DL_FUNC and wraps it with R_MakeExternalPtrFn (tagged as a native symbol). make_callable() then passes that external pointer to .RtinyccCall (which is base::.Call). There is no Rf_install cast of the function pointer; Rf_install only sets the native symbol tag.

Type system highlights

Scalar types: i8, i16, i32, i64, f32, f64, bool, cstring. Array arguments (zero-copy): raw, integer_array, numeric_array, logical_array, character_array. Array returns: returns = list(type = "*_array", length_arg = <index>, free = TRUE) copies into a new R vector and optionally frees the C buffer. Struct array fields: list(type = "u8", size = N, array = TRUE) generates element accessors struct_<name>_get_<field>_elt() / struct_<name>_set_<field>_elt(). Pointers: ptr and sexp are exposed as external pointers; ownership is tracked and enforced in RC_free and tcc_ptr_is_owned().

Discussion

0/2000
Loading comments...

Health Signals

MaintenanceCommitted 1mo ago
Active
AdoptionUnder 100 stars
8 ★ · Niche
DocsMissing or thin
Undocumented

GitHub Signals

Stars8
Issues0
Updated1mo ago
View on GitHub
GPL-3.0 License

My Fox Den

Community Rating

Sign in to rate this booster

Works With

Any AI assistant that accepts custom rules or system prompts

Claude
ChatGPT
Cursor
Windsurf
Copilot
+ more