mohitmishra786/low-level-dev-skills / skills/compilers/clang
clang
VerifiedClang/LLVM compiler skill for C/C++ projects. Use when working with clang or clang++ for diagnostics, sanitizer instrumentation, optimization remarks, static analysis with clang-tidy, LTO via lld, or when migrating from GCC to Clang. Activates on queries about clang flags, clang-tidy, clang-format, better error messages, Apple/FreeBSD toolchains, or LLVM-specific optimizations. Covers flag selection, diagnostic tuning, and integration with LLVM tooling.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.5 KB |
| references/clang-tidy.md | markdown | 1.9 KB |
| references/flags.md | markdown | 3.9 KB |
references/clang-tidy.md
View on GitHub# clang-tidy Reference
Source: <https://clang.llvm.org/extra/clang-tidy/>
## Configuration (.clang-tidy)
```yaml
---
Checks: >
clang-analyzer-*,
bugprone-*,
modernize-*,
performance-*,
readability-identifier-naming,
-modernize-use-trailing-return-type,
-readability-magic-numbers
WarningsAsErrors: 'bugprone-*'
HeaderFilterRegex: '.*'
FormatStyle: file
CheckOptions:
- key: readability-identifier-naming.VariableCase
value: camelCase
```
## Common invocations
```bash
# Single file
clang-tidy src.cpp -- -std=c++17 -I./include
# All files using compile_commands.json
clang-tidy $(find src -name '*.cpp') -p build/
# Apply fixits (creates in-place changes)
clang-tidy -fix src.cpp -- -std=c++17
# Parallel (requires run-clang-tidy script)
run-clang-tidy -j4 -p build/ 2>&1 | tee tidy.log
# Generate compile_commands.json with CMake
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S . -B build
ln -sf build/compile_commands.json .
```
## Key check families
| Family | Description |
|--------|-------------|
| `bugprone-*` | Use-after-move, dangling reference, suspicious constructs |
| `clang-analyzer-*` | CSA: memory leaks, null deref, API misuse |
| `modernize-*` | C++11/14/17/20 upgrade patterns |
| `performance-*` | Unnecessary copies, pass-by-value candidates |
| `readability-*` | Naming, complexity, clarity |
| `cppcoreguidelines-*` | C++ Core Guidelines |
| `cert-*` | CERT coding standard checks |
| `hicpp-*` | HIC++ standard checks |
| `portability-*` | Cross-platform issues |
## Suppressing checks
```cpp
// NOLINT: suppress all checks on this line
int x = getValue(); // NOLINT
// NOLINT(check-name): suppress specific check
int y = getValue(); // NOLINT(bugprone-narrowing-conversions)
// NOLINTNEXTLINE: suppress on next line
// NOLINTNEXTLINE(modernize-use-auto)
MyType* ptr = new MyType();
```
In `.clang-tidy`, prefix a check with `-` to disable:
```yaml
Checks: 'modernize-*,-modernize-use-trailing-return-type'
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Unverified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |