Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计通过

coding-guidance-cpp编码指导 cpp

Agent Skill

coding-guidance-cpp 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

404

周安装

17

GitHub Stars

3

下载量

141
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:coding-guidance-cpp(编码指导 cpp)
来源仓库:https://github.com/n-n-code/n-n-code-skills
仓库路径:skills/coding-guidance-cpp
安装命令:
npx skills add https://github.com/n-n-code/n-n-code-skills --skill coding-guidance-cpp
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/n-n-code/n-n-code-skills --skill coding-guidance-cpp

简介

coding-guidance-cpp 针对 C++ 跨平台开发提供实现、重构与审查建议,强调内存安全与异常处理。

  • 适用于后端系统与 UI 开发,支持强类型约束与构建工具链集成(如 CMake)。
  • 不建议用于裸金属或极端性能优化场景,优先选用标准库替代自定义容器实现。
  • 使用前请确认编译器版本支持 C++17/20 特性,并检查第三方依赖许可证兼容性。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

C++ Coding Guidance

This skill adds portable C++ implementation, refactoring, and review guidance.

Adjacent Skills

This skill provides portable C++ engineering principles. Compose with:

  • Workflow: thinking (planning), recursive-thinking (stress-testing), security (threat modeling)
  • Domain overlays: backend-guidance (server-side code), backend-systems-guidance (stronger backend architecture, reliability, and trust-boundary work), ui-guidance (graphical UI/web frontend), project-core-dev (repo-specific build/test commands)

When Not to Lean on This Skill

  • non-C++ work
  • legacy or bare-metal environments where modern C++ guidance must be adapted selectively
  • pure architecture or process work with no C++ design or code judgment needed
  • repo-specific style packs or platform policies that should be enforced by local clang-tidy, compiler, or overlay rules rather than a portable principle skill

Boundary Contract

Keep this skill focused on portable C++ engineering judgment.

  • Put repo-specific exception policy, warning policy, formatter choices, and include-order rules in repo config or repo docs
  • Put style-pack rules from ecosystems such as Google, LLVM, Abseil, or platform/vendor bundles in repo config or overlays, not here
  • Put library- or platform-specific API policy in repo config or a domain overlay
  • When a rule is analyzer-shaped but not portable, keep it in clang-tidy config or the reference note rather than adding it to the main skill

Implementation Workflow

  1. Read the touched code, build shape, existing tests, and any nearby docs or shorthand notes before editing.
  2. If the request is partially specified, infer the intended behavior from the existing code and tests. Ask only when multiple plausible C++ designs would change semantics.
  3. Choose the narrowest change that solves the problem without hiding ownership, lifetime, or error-handling contracts.
  4. Implement with simple, strongly typed interfaces and modern C++ defaults.
  5. Add or update tests close to the changed behavior.
  6. Run the narrowest relevant format, build, test, sanitizer, and analyzer targets the repo supports.

Refactoring Workflow

Use this instead of the default implementation workflow when the task is primarily cleanup or restructuring:

  1. Capture current behavior, invariants, side effects, and risky hotspots.
  2. Break the refactor into small slices that preserve behavior.
  3. Remove duplication, long functions, or muddled responsibilities one step at a time.
  4. Keep tests passing after each slice; add characterization coverage first when behavior is unclear.
  5. Stop when the code is simpler and safer.

Review Workflow

When reviewing (not implementing), skip the implementation workflow and use this instead:

  1. Read the change in full before commenting.
  2. Identify findings, ordered by severity: Critical > Important > Suggestion.
  3. Prioritize bugs and regressions, ownership and lifetime errors, exception or error-path holes, thread-safety issues, security risks, performance mistakes with real impact, and missing tests.
  4. State findings with concrete evidence and the likely consequence.

C++ Rules

Read these by failure theme, not as an exhaustive checklist.

Construction, ownership, and lifetime

  • Treat raw pointers and references as non-owning; never transfer ownership by raw pointer or reference
  • Avoid new and delete; bind resource lifetime to object lifetime with RAII
  • Prefer std::unique_ptr by default; use std::shared_ptr only for real shared lifetime and std::weak_ptr to break cycles
  • Prefer values and stack allocation over heap allocation when ownership is simple
  • Prefer rule-of-zero types; if you write a destructor or custom special member function, justify it
  • Initialize objects into valid states immediately; construction should establish invariants instead of relying on later “remember to initialize” steps
  • Do not store or return references, views, iterators, or pointers into temporaries or short-lived owners; when the lifetime proof is not obvious, return or store an owning value instead
  • Treat moved-from objects as valid but semantically narrow; only destroy, reassign, or call operations whose post-move contract is explicit
  • Do not cross async, callback, coroutine-suspend, or thread-handoff boundaries with borrowed state unless the lifetime proof is explicit

Type, bounds, and representation safety

  • Avoid unchecked bounds access; prefer .at(), iterators, range-for, or std::span when bounds are uncertain
  • Avoid silent narrowing conversions; use explicit casts or narrowing helpers
  • Avoid signed/unsigned comparison traps; use std::cmp_*, std::in_range, or a deliberate common type when integer domains differ
  • Prefer compile-time checking to runtime checking when the type system can express the rule
  • Avoid C-style casts; use static_cast, const_cast, reinterpret_cast, and dynamic_cast deliberately
  • Prefer std::bit_cast or byte-wise copy for object-representation reinterpretation; do not use reinterpret_cast where aliasing or lifetime rules make the behavior fragile
  • Avoid raw memory APIs, memset/memcpy tricks, or pointer arithmetic on non-trivial, polymorphic, or lifetime-sensitive types
  • Use const and constexpr by default; mutability should be the exception
  • Prefer enum class over plain enums and nullptr over NULL
  • Prefer std::array over C arrays, std::string_view for non-owning strings, and std::span for non-owning ranges when lifetime rules are clear

API contracts and call-site clarity

  • Do not mix exception and error-code styles inconsistently inside one path
  • Do not ignore must-check results from allocation, parsing, synchronization, numeric conversion, or OS/library APIs when failure changes behavior
  • Use [[nodiscard]] when ignoring a result is likely a bug
  • Prefer explicit constructors, conversions, and named types when ownership, units, or semantics would otherwise be implicit
  • Avoid forwarding, overload, and default-argument combinations that make calls ambiguous or silently select the wrong overload
  • Treat virtual dispatch boundaries as bug-prone: use override, avoid near misses, and do not rely on shadowing or signature accidents
  • Keep declarations and definitions consistent across headers and sources: parameter names, qualifiers, defaults, and ownership cues should not drift
  • Be suspicious of adjacent same-type parameters; named types, parameter objects, or strong typedefs are often clearer than comments
  • Prefer interfaces that make argument order hard to misuse and bool/int/string sentinels hard to confuse
  • Prefer APIs that encode units, domains, and nullability in types rather than relying on comments, magic values, or positional conventions

Headers, globals, and build surface

  • Avoid using namespace std in headers
  • Keep warnings at zero in repo-owned code
  • Keep macros narrow, parenthesized, side-effect-safe, and out of API shaping; prefer language features unless a macro is the least-bad tool
  • Avoid reserved identifiers, namespace pollution, and definitions in headers that quietly change ODR or rebuild behavior
  • Prefer include sets that are minimal and explicit; unused includes, include cycles, and transitive-include dependence are design smells
  • Use constinit for non-local static or thread-local objects that must not rely on dynamic initialization
  • Prefer compile-time constants, local statics, or explicit startup wiring over hidden global initialization side effects

Concurrency, async, and testability

  • Prefer structured thread ownership and explicit cancellation over detached threads or ad hoc stop flags; std::jthread and std::stop_token are good defaults when the codebase already uses standard thread primitives
  • Assume container modifications may invalidate iterators, references, pointers, and views unless the container contract says otherwise
  • Prefer seams that keep core logic testable without real threads, clocks, filesystem, process state, or ambient globals when the domain does not require those dependencies

Expressive modern defaults

  • Prefer vocabulary types such as std::optional, std::variant, and std::expected when they encode real domain states better than sentinels or ad hoc conventions
  • Prefer standard algorithms and ranges over open-coded loops when they make the intent clearer
  • Prefer standard library and language replacements for deprecated, legacy-C-leaning, or handwritten utilities when the replacement is clearer and already acceptable in the repo toolchain

Advanced design judgment

Load references/cpp-advanced-design-judgment.md when the task involves public APIs, error-model choices, advanced language features, template-heavy interfaces, headers with broad rebuild impact, coroutines, synchronization strategy, ABI/plugin/C interop boundaries, or abstraction design. Keep ordinary feature work in the default rules above.

Clang-Tidy-derived emphasis

Use the full clang-tidy catalog as a source of recurring failure modes, not as a portable checklist to paste into every repo.

  • Treat bugprone, cppcoreguidelines, modernize, performance, misc, portability, and the CERT/HIC++ aliases as high-signal prompts for code review and refactoring
  • Fold only portable semantics into this principle skill; repo-specific naming, include order, formatter preferences, test-framework style, platform APIs, and library-pack rules belong in repo config or overlays
  • If a repo ships clang-tidy, read its enabled checks before introducing new patterns; local suppressions and allowlists often document real constraints
  • When multiple checks point at the same design issue, fix the design cause instead of satisfying each warning mechanically

Resource map

Decision Heuristics

Use these when the right choice is not obvious:

  • Scope check: if a change touches more than 3 public interfaces, stop and plan before continuing; the change is bigger than it looks.
  • Ownership clarity: if ownership is not obvious from the type signature, redesign the interface or add a one-line contract comment.
  • Error-model consistency: do not mix exceptions, error codes, and expected-style returns within one subsystem unless the boundary is explicit.
  • Exception-safety pressure: when mutating multi-step state, decide whether the operation offers no-fail, strong, or basic exception safety and structure the code to match.
  • Repo conventions: if the repo has established rules for exceptions, containers, ownership types, or naming, follow them unless they create a correctness or safety problem.
  • Feature pressure: do not introduce concepts, ranges, coroutines, or metaprogramming unless they make the code simpler for this repo's likely maintainers.
  • Interface pressure: if a header starts dragging in broad dependencies or exposing implementation detail, narrow the interface before adding more code.
  • Build-surface pressure: if a design pushes more logic, templates, or dependencies into public headers, justify the compile-time and rebuild cost.
  • Parameter pressure: when adjacent parameters have the same type, or the function needs more than 2-3 meaningful inputs, prefer a named type or helper struct.
  • Lifetime pressure: if a non-owning type crosses async, callback, return, or storage boundaries, prefer an owning type unless the lifetime proof is obvious from the interface.
  • Initialization pressure: if correct behavior depends on a later “remember to initialize” step, move that requirement into construction or the type itself.
  • Call-site pressure: if two arguments are easy to swap or a call needs comments to explain literals, redesign the API before adding more call sites.
  • Header pressure: if a header starts accumulating definitions, globals, unnecessary includes, or hidden initialization, push behavior back behind a source boundary.
  • Testability pressure: if a design forces tests to spin threads, sleep, touch the real filesystem, or patch globals just to exercise core logic, introduce a seam before adding more behavior.
  • Test setup size: if test setup exceeds about 20 lines, extract a fixture only when the setup is reused or the test intent becomes unclear.
  • Narrowness vs. quality: implement the narrowest change that solves the problem. When narrowness conflicts with correctness or safety, prefer correctness. When it conflicts with style alone, prefer narrowness unless the task is explicitly a cleanup.
  • Refactor boundary: outside explicit refactor work, fix at most one small adjacent issue while you are in the file.
  • Abstraction threshold: three similar code blocks or repeated API-shaping pain is a pattern; before extracting, check whether a free function, helper type, or composed object is the simpler move.
  • Performance rule: optimize only after measurement, except for obvious ownership, allocation, or algorithmic mistakes on hot paths.
  • UB-sensitive optimization: treat optimizations that rely on subtle lifetime, aliasing, or memory-order assumptions as high-risk until proven by evidence and tooling.

Validation

A change is done when:

  • the code compiles without new warnings, unless the repo explicitly treats a known warning set as baseline debt outside the change
  • existing tests pass
  • new or changed behavior has test coverage, or the lack of coverage is called out with a concrete reason
  • the repo's formatter has been run
  • configured static analyzers report no new findings
  • available sanitizers are clean for the touched paths when the change affects memory safety, threading, or undefined-behavior risk
  • performance-sensitive changes are measured instead of justified by intuition
  • review findings at Critical and Important severity are addressed

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.96%
按下载量换算55

Claude

28.19%
按下载量换算40

Cursor

18.5%
按下载量换算26

Gemini CLI

9.97%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills