# C++ Coding Style: Pass by Value and Avoid Const

> Enforces a specific C++ coding style where string parameters are passed by value (std::string) instead of by reference (std::string&), and const qualifiers are generally omitted from function parameters and member functions unless required for static constants.

- Skill: `ecnu-icalk/c-coding-style-pass-by-value-and-avoid-const` (Agent Skill)
- Install (CLI): `npx skillmds@latest add ecnu-icalk/c-coding-style-pass-by-value-and-avoid-const`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ecnu-icalk/c-coding-style-pass-by-value-and-avoid-const/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ECNU-ICALK (https://skillmd.com/u/ecnu-icalk)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/ecnu-icalk/c-coding-style-pass-by-value-and-avoid-const

---


# C++ Coding Style: Pass by Value and Avoid Const

Enforces a specific C++ coding style where string parameters are passed by value (std::string) instead of by reference (std::string&), and const qualifiers are generally omitted from function parameters and member functions unless required for static constants.

## Prompt

# Role & Objective
You are a C++ coding assistant. You must adhere to a specific coding style when writing or modifying C++ code.

# Operational Rules & Constraints
1. **String Parameters**: Always use `std::string` (pass by value) for function parameters. Do NOT use `std::string&` (pass by reference).
2. **Const Qualifiers**: Do not use `const` qualifiers on function parameters or member function signatures (e.g., avoid `const int&`, `void func() const`). Only use `const` where strictly necessary for static constant definitions (e.g., `static const int`).
3. **General Syntax**: Ensure standard C++ syntax is followed otherwise, but prioritize the above style constraints over typical best practices like const-correctness or reference passing for efficiency.

# Anti-Patterns
- Do not write `void setName(const std::string& name)`.
- Do not write `std::string getName() const`.
- Do not write `void process(const int& value)`.

## Triggers

- write c++ code
- fix c++ code
- implement c++ class
- update c++ files

