fprime-cpp-design
Fungsinya
Skill ini mencantumkan aturan desain C dan C++ yang harus diikuti kode penerbangan F Prime, misalnya menghindari memori dinamis setelah startup. Skill ini untuk insinyur yang menulis kode F Prime.
Kapan dipakai
- βSaat Anda menulis atau mengubah kode C++ di komponen F Prime.
- βSaat Anda ingin tahu tipe dan idiom pengkodean F Prime mana yang harus dipakai.
- βSaat Anda meninjau kode F Prime dan perlu aturan di balik sebuah komentar.
Link skill
https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-cpp-design/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBisakah Anda memeriksa apakah fungsi C++ F Prime ini mengikuti aturan desain perangkat lunak penerbangan?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
AI membandingkan kode dengan aturan desain yang bernomor, menjelaskan aturan mana yang dilanggar oleh setiap masalah, lalu menyarankan perbaikan yang mengikuti aturan tersebut.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Skill: F Prime C/C++ design rules
The single source of truth for the C/C++ design rules F Prime flight software is held to. Used in two directions:
- Developer-side. Β§1 is positive guidance for writing or modifying F Prime C++ code.
- Reviewer-side. Β§2 gives the finding-class name to use per
rule; Β§3 gives severity hints. Combine with
.github/skills/triage-classifier/SKILL.md.
External references in Β§4 are authoritative for their specific clauses; this skill summarizes the rules the agents enforce. Where this skill and an external reference disagree, this skill wins for review purposes.
1. The rules
Rules are grouped by theme. Numbers are stable and may be cited in PR comments and in other agent files.
A. Memory & lifetime
CPP-1 β No dynamic memory after initialization
Allocate all dynamic storage during component initialization or
boot. After init, no new / delete / malloc / free, and no
implicit allocation through STL containers, std::string, or
exception machinery (see CPP-25).
Allowed: pre-sized arrays sized at compile or init time, Fw::Buffer
references to memory owned elsewhere (CPP-2), object pools allocated
once at boot.
// Avoid (allocation post-init)
char* scratch = new char[len];
// Prefer (sized at declaration)
static constexpr U32 SCRATCH_BYTES = 256;
U8 m_scratch[SCRATCH_BYTES];
CPP-2 β Fw::Buffer ownership transfers must close in every branch
Any function receiving an Fw::Buffer must, in every branch
(success, failure, error, early-return), either transfer ownership
out (pass to another component, store in a tracked slot) or
return it to the sender. A dropped Fw::Buffer leaks; a
double-transferred one is a use-after-free.
CPP-17 β Follow Rule of Three / Rule of Five
If a class manages a resource (raw pointer, file handle, externally-
owned memory), implement (or = delete) all of: destructor, copy
constructor, copy assignment, and β under Rule of Five β move
constructor and move assignment. Most F Prime components are not
intended to be copied; mark the copy ops = delete explicitly.
CPP-19 β Initialize all variables
Every variable β member, local, global β has an explicit
initializer. Uninitialized reads are undefined behavior. Prefer
member-initializer lists for class members; use brace-initialization
(Type x{}; or Type x{value};) for locals.
CPP-20 β Destructors are virtual or protected non-virtual
A class meant to be inherited from declares either a virtual
destructor (polymorphic deletion is safe) or a protected
non-virtual destructor (deletion through the base pointer is
prevented).
B. Asserts and untrusted inputs
CPP-4 β FW_ASSERT is for programming errors only
FW_ASSERT is for programmer-controllable invariants β
guaranteed by construction. It is not input validation. Never
FW_ASSERT on a value reachable from:
- A ground command argument (see
.github/skills/fprime-ground-input-tracing/SKILL.md). - A hardware input β packet, register read, port from a driver (see
.github/skills/fprime-hardware-input-tracing/SKILL.md). - Any off-device data crossing a hub / bridge / driver boundary.
Validate untrusted inputs and return the error through the
component's contract (typically a VALIDATION_ERROR command
response, a sized return, or a soft-failure event). The
security-review agent mirrors this as ground-reachable-assert /
hardware-reachable-assert; CPP-4 is the C++-side framing of the
same finding.
C. F Prime types and idioms
CPP-3 β Always use fixed-size numerical types
For numerical fields (integers, floats), always use a fixed-size type unless an external API forces a non-fixed-size type. Fixed-size types are either:
- The explicit fixed-size types:
U8,I8,U16,I16,U32,I32,U64,I64,F32,F64. - The configurable
Fw*types whose width the project pins to a known fixed-size type at config time (e.g.,FwSizeType,FwIndexType).
Bare C/C++ numerical types (int, unsigned, long, size_t,
float, double) are forbidden in F Prime code except at external
API boundaries that require them.
CPP-28 β Prefer configurable Fw* types when range may vary across projects
When the appropriate width for a value depends on the project (e.g.,
buffer sizes, container indices, time tick counts), use the
configurable Fw* type rather than a bare fixed-size type. The
configurable type lets the f
Pertanyaan umum
Apakah kode mengalokasikan memori setelah startup?
Aturannya menghindari memori dinamis setelah inisialisasi, sehingga penyimpanan diukur dan dialokasikan saat startup.
Bagaimana aturannya disusun?
Aturannya diberi nomor dan dikelompokkan berdasarkan tema, misalnya memori dan masa hidup.
Apakah ini menggantikan panduan gaya?
Tidak. Skill ini merangkum aturan yang ditegakkan proyek dan menunjuk ke referensi luar untuk klausul tertentu.
Detail
Deskripsi asli dari pembuat
Authoritative C/C++ design rules and idioms for F Prime flight software. Use this skill in two directions β as a *developer-side* reference when writing or modifying F Prime C++ code (what idioms to follow, what features to avoid, which F Prime types to prefer), and as a *reviewer-side* reference for finding-class names and severity hints when flagging C/C++ design violations. Trigger on any work that touches F Prime C/C++ source: component implementations, drivers, services, framework types, OSAL code, or unit-test infrastructure. Keywords: F Prime, C++14, FW_ASSERT, Fw::Buffer, Fw::String, J
repo: nasa/fprime
Popularitas
- Bintang GitHub
- 12k
- Peringkat
- #11500
- Lisensi
- Apache-2.0
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
fprime-cmake-build-system
12kMembantu agent Anda menambahkan modul, target build, dan pengaturan platform ke proyek perangkat lunak penerbangan F Prime melalui lapisan CMake-nya.
fprime-component-design-fpp
12kMembantu agent Anda mengubah persyaratan komponen F Prime yang sudah disetujui menjadi model FPP untuk port, perintah, event, dan telemetri-nya.
fprime-component-development
12kMembantu agent Anda memandu komponen F Prime melalui setiap fase pengembangan, dari persyaratan hingga tes integrasi.
fprime-component-implementation
12kMembantu agent Anda menulis kode C++ di balik fungsi handler yang dihasilkan untuk komponen F Prime, dengan mengikuti aturan proyek.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.