Skip to main content
ai-slop/cpp-using-namespace-std-in-headermanual fix

using namespace std in a header.

`using namespace std;` in a header file. Every file that includes the header inherits the whole `std` namespace and the name clashes that come with it.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

cpp-using-namespace-std-in-header.cpp
✗ Flagged
// report.hpp
#pragma once
#include <string>
#include <vector>

using namespace std;

string render(const vector<string>& lines);
Why this trips

Deterministic line match: flags lines that start with `using namespace std;` in `.h`, `.hh`, `.hpp`, and `.hxx` files.

cpp-using-namespace-std-in-header.cpp
✓ Clean
// report.hpp
#pragma once
#include <string>
#include <vector>

std::string render(const std::vector<std::string>& lines);
What changed

Qualify names with `std::` in headers. If you want the directive, put it in a `.cpp` file or inside a function.

Agents add the directive to save typing `std::`, without distinguishing a header from an implementation file.

How this rule is justified.

Rule id

ai-slop/cpp-using-namespace-std-in-header

Enforcing engine

ai-slop

Detector strategy

Deterministic line match: flags lines that start with `using namespace std;` in `.h`, `.hh`, `.hpp`, and `.hxx` files.

Legitimate code that is NOT flagged

The directive in `.cpp`/`.cc` implementation files, and narrow using-declarations such as `using std::string;`, are not flagged.

Evidence

Part of aislop's C/C++ rule set. C/C++ support, including C/C++-specific AI-slop rules, arrived in aislop v0.14.1.