- Applies to this STL C++ project and its subdirectories
This is a standard C++ project using the STL (Standard Template Library).
- Type: cmake
- Build file: CMakeLists.txt
- Build commands:
mkdir -p build && cd build cmake .. make -j$(nproc)
- Use
#pragma onceor include guards:#ifndef PROJECT_HEADER_H #define PROJECT_HEADER_H // content #endif
This project uses STL (Standard Template Library):
std::stringfor stringsstd::vector<T>,std::array<T>for containersstd::map<K,V>,std::unordered_map<K,V>for associative containersstd::unique_ptr<T>,std::shared_ptr<T>for smart pointersstd::optional<T>for optional values (C++17)
Use modern C++ features when appropriate:
- Range-based for loops:
for (const auto& item : container) - Auto type deduction:
auto value = someFunction(); - Smart pointers instead of raw
new/delete - RAII (Resource Acquisition Is Initialization)
nullptrinstead ofNULLconstexprfor compile-time constants
- Prefer smart pointers (
std::unique_ptr,std::shared_ptr) - Avoid raw
new/delete- use RAII containers - Use
std::make_uniqueandstd::make_shared
Follow project-specific naming conventions (common styles):
- Classes/Structs:
PascalCaseorClassName - Functions/Methods:
camelCaseorsnake_case - Variables:
camelCaseorsnake_case - Constants:
UPPER_SNAKE_CASEorkConstantName - Namespaces:
lowercaseorsnake_case
- Header files:
.hor.hpp - Implementation files:
.cppor.cc - Inline implementations:
.inl(if used)
// Range-based (preferred)
for (const auto& item : container) {
// use item
}
// Traditional iterator
for (auto it = container.begin(); it != container.end(); ++it) {
// use *it
}std::string str = "hello world";
auto pos = str.find("world");
if (pos != std::string::npos) {
// found
}
std::string sub = str.substr(0, 5);std::vector<int> vec;
vec.push_back(42);
vec.emplace_back(43); // construct in-place
std::map<std::string, int> map;
map["key"] = value;
auto it = map.find("key");
if (it != map.end()) {
// found
}- Enable debug symbols:
-g - Disable optimization:
-O0 - Enable sanitizers:
-fsanitize=address,undefined
- Enable optimization:
-O2or-O3 - Strip symbols:
-s - Link-time optimization:
-flto
-Wall -Wextra- Enable warnings-Werror- Treat warnings as errors-std=c++17or-std=c++20- C++ standard version-pthread- Threading support
Check the following files for dependencies:
- CMakeLists.txt - CMake dependencies
- Makefile - Make dependencies
- README.md - Manual dependency list
- requirements.txt or similar
- Code comments should explain "why", not "what"
- Use Doxygen-style comments for API documentation
- Keep README.md updated with build instructions
If the project has tests:
- Unit tests are usually in
test/ortests/directory - Run tests after building to ensure correctness
- Add tests for new features
See agents/common-workflow.md for complete workflow patterns.
- Use
TASKS.mdfor task tracking with sections: TODO, IN_PROGRESS, DONE - Tasks belong to phases (Phase 1, Phase 2, etc.)
- Update TASKS.md after every completed task
- CRITICAL: When you discover new tasks during work, ADD them to TASKS.md immediately
- Don't wait - document new tasks as soon as you realize they're needed
- Examples: "Need password reset", "Found security issue", "Missing tests"
- Add to appropriate phase in TODO section
- BEFORE committing: Run build and test scripts if they exist
- Commit format:
Task X.Y: Description - ALWAYS push after commit
- C++ Reference
- C++ Core Guidelines
- Project-specific documentation in README.md