fprime-cpp-design
できること
F Primeの飛行コードが従わなければならないC言語とC++の設計ルールを挙げます。起動後の動的メモリを避けるなど、ルールを一覧で示します。F Primeのコードを書くエンジニア向けです。
使う場面
- ✓F PrimeのコンポーネントでC++のコードを書いたり変更したりするとき。
- ✓どのF Primeの型やコーディングの作法を使うべきか知りたいとき。
- ✓F Primeのコードをレビューし、あるコメントの根拠になったルールを知りたいとき。
スキルのリンク
https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-cpp-design/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“このF PrimeのC++関数が、飛行ソフトウェアの設計ルールに従っているか確認してもらえますか。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIはコードを番号付きの設計ルールと比べ、どのルールに反しているかを説明し、そのルールに従った修正案を示します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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
よくある質問
起動後にコードはメモリを確保しますか?
ルールは、初期化後の動的メモリを避けるため、ストレージは起動時にサイズを決めて確保します。
ルールはどう整理されていますか?
メモリや寿命などのテーマごとに、番号を付けてまとめられています。
スタイルガイドの代わりになりますか?
いいえ。プロジェクトが適用するルールを要約し、特定の条項については外部の参考資料を示します。
詳細
作者による元の説明
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
人気
- GitHubのスター
- 12k
- ランキング
- #11500
- ライセンス
- Apache-2.0
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
fprime-cmake-build-system
12kエージェントが、CMakeの層を通じて、F Primeの飛行ソフトウェアのプロジェクトにモジュール、ビルドのターゲット、プラットフォームの設定を追加できるよう支援します。
fprime-component-design-fpp
12kエージェントが、承認されたF Primeのコンポーネント要件を、ポート、コマンド、イベント、テレメトリのFPPモデルに変換できるよう支援します。
fprime-component-development
12kエージェントが、要件からインテグレーションテストまで、F Primeのコンポーネントを各開発フェーズで進められるよう支援します。
fprime-component-implementation
12kエージェントが、プロジェクトのルールに従って、F Primeのコンポーネントの自動生成されたハンドラー関数の裏にあるC++のコードを書けるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。