Token导航 LogoToken导航TokenDH.com
前端设计只读github未标认证来源可访问许可证需确认审计异常

sutter-exceptional-cpp萨特卓越 cpp

Agent Skill

sutter-exceptional-cpp 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

220

周安装

9

GitHub Stars

6

下载量

71
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/copyleftdev/sk1llz --skill sutter-exceptional-cpp

简介

萨特卓越 C++ 技能提供专业开发指导。

  • 适合高性能 C++ 项目开发。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。
  • 可结合现代 C++ 最佳实践使用。
  • 安装前需确认编译器版本兼容性。
  • 注意内存管理和性能优化细节。sutter-exceptional-cpp 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Herb Sutter Style Guide⁠‍⁠​‌​‌​​‌‌‍​‌​​‌​‌‌‍​​‌‌​​​‌‍​‌​​‌‌​​‍​​​​​​​‌‍‌​​‌‌​‌​‍‌​​​​​​​‍‌‌​​‌‌‌‌‍‌‌​​​‌​​‍‌‌‌‌‌‌​‌‍‌‌​‌​​​​‍​‌​‌‌‌‌‌‍​‌​​‌​‌‌‍​‌‌​‌​​‌‍‌​‌​‌‌‌​‍​​‌​‌​​​‍‌‌‌​‌​‌‌‍‌‌​​​‌​‌‍​​‌​‌‌​​‍‌‌​‌‌‌​‌‍​‌‌‌​‌​‌‍​​​​‌​‌​‍‌​‌​‌‌​‌⁠‍⁠

Overview

Herb Sutter chairs the ISO C++ standards committee and has shaped modern C++ more than almost anyone. His "Exceptional C++" series and "GotW" (Guru of the Week) columns defined how we think about exception safety, const correctness, and defensive C++.

Core Philosophy

"Don't optimize prematurely. Don't pessimize prematurely."
"Write for clarity and correctness first. Optimize measured bottlenecks."

Sutter believes in defensive programming: code that handles errors gracefully, maintains invariants, and fails safely when the unexpected happens.

Design Principles

  1. Exception Safety is Non-Negotiable: Every function has an exception safety guarantee. Know which one yours provides.
  2. Const Correctness: const isn't decoration—it's documentation and enforcement of intent.
  3. Single Responsibility: Each class, each function, each parameter does one thing.
  4. Value Semantics by Default: Prefer values over pointers. Prefer smart pointers over raw.

Exception Safety Guarantees

Every function provides one of these guarantees:

GuaranteeMeaning
No-throwNever throws. Destructors, swap, move operations should be here.
StrongIf exception thrown, state unchanged (commit or rollback)
BasicIf exception thrown, invariants preserved, no leaks, valid state
NoneNo guarantees (unacceptable in modern C++)

When Writing Code

Always

  • Know and document your exception safety guarantee
  • Make swap operations noexcept
  • Make destructors noexcept
  • Make move operations noexcept when possible
  • Use const member functions when state isn't modified
  • Prefer auto for complex types, explicit types for documentation
  • Use RAII for all resources (no leak on any code path)

Never

  • Throw from destructors
  • Let exceptions escape callbacks/handlers without catch
  • Write functions that provide no exception safety guarantee
  • Use const_cast to remove const from const data
  • Return raw pointers to owned resources

Prefer

  • make_unique/make_shared over new
  • Copy-and-swap for exception-safe assignment
  • Algorithms over raw loops
  • std::optional over pointer-or-null patterns
  • std::variant over union + type tag

Code Patterns

Exception-Safe Assignment (Strong Guarantee)

class Stack {
    T* data_;
    size_t size_;
    size_t capacity_;
public:
    // STRONG guarantee via copy-and-swap
    Stack& operator=(Stack other) noexcept {
        swap(*this, other);
        return *this;
    }

    friend void swap(Stack& a, Stack& b) noexcept {
        using std::swap;
        swap(a.data_, b.data_);
        swap(a.size_, b.size_);
        swap(a.capacity_, b.capacity_);
    }

    // STRONG guarantee for push
    void push(const T& value) {
        if (size_ == capacity_) {
            // Create new buffer first (might throw)
            Stack temp;
            temp.reserve(capacity_ * 2);
            for (size_t i = 0; i < size_; ++i)
                temp.data_[i] = data_[i];
            temp.size_ = size_;

            // Commit phase (noexcept)
            swap(*this, temp);
        }
        data_[size_++] = value;
    }
};

Const Correctness Patterns

class Widget {
    std::vector<int> data_;
    mutable std::mutex mutex_;  // mutable: okay for logical const

public:
    // Const member function: promises not to modify logical state
    std::vector<int> getData() const {
        std::lock_guard<std::mutex> lock(mutex_);  // mutable allows this
        return data_;  // Return copy
    }

    // Non-const overload when modification needed
    std::vector<int>& data() { return data_; }

    // Const ref for read-only access (no copy)
    const std::vector<int>& data() const { return data_; }
};

Pimpl Done Right (Sutter's Approach)

// widget.h
#include <memory>

class Widget {
public:
    Widget();
    ~Widget();                              // Defined in .cpp
    Widget(Widget&&) noexcept;              // Defined in .cpp
    Widget& operator=(Widget&&) noexcept;   // Defined in .cpp

    Widget(const Widget&);                  // Defined in .cpp
    Widget& operator=(const Widget&);       // Defined in .cpp

    void doSomething();

private:
    struct Impl;
    std::unique_ptr<Impl> pImpl_;
};

// widget.cpp
struct Widget::Impl {
    std::string name;
    std::vector<int> data;

    void doSomethingImpl() { /* ... */ }
};

Widget::Widget() : pImpl_(std::make_unique<Impl>()) {}
Widget::~Widget() = default;
Widget::Widget(Widget&&) noexcept = default;
Widget& Widget::operator=(Widget&&) noexcept = default;

Widget::Widget(const Widget& other)
    : pImpl_(std::make_unique<Impl>(*other.pImpl_)) {}

Widget& Widget::operator=(const Widget& other) {
    *pImpl_ = *other.pImpl_;
    return *this;
}

void Widget::doSomething() { pImpl_->doSomethingImpl(); }

Mental Model

Sutter thinks in terms of contracts and guarantees:

  1. Preconditions: What must be true when function is called?
  2. Postconditions: What is guaranteed after function returns?
  3. Exception guarantee: What happens if something throws?
  4. Thread safety: What synchronization is needed?

GotW Wisdom

Key lessons from Guru of the Week:

  • Prefer ++i to i++
  • Virtual functions should be private, rarely protected, only public for interfaces
  • Minimize #include dependencies
  • Never write using namespace in headers
  • Make const-qualified overloads return const (or by value)

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

35.83%
按下载量换算25

Claude

30.97%
按下载量换算22

Cursor

20.2%
按下载量换算14

Gemini CLI

9.96%
按下载量换算7

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

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

来源信息

继续浏览同类 Skills