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에이전트가 F Prime 비행 소프트웨어 프로젝트의 CMake 계층을 통해 모듈, 빌드 타깃, 플랫폼 설정을 추가하도록 돕습니다.
fprime-component-design-fpp
12k에이전트가 승인된 F Prime 컴포넌트 요구사항을 포트, 명령, 이벤트, 텔레메트리의 FPP 모델로 바꾸도록 돕습니다.
fprime-component-development
12k에이전트가 요구사항에서 통합 테스트까지, F Prime 컴포넌트를 각 개발 단계마다 안내하도록 돕습니다.
fprime-component-implementation
12k에이전트가 F Prime 컴포넌트의 자동 생성된 핸들러 함수에 들어갈 C++ 코드를 프로젝트 규칙에 맞춰 작성하도록 돕습니다.