Optimization Passes for Your Repo
Published
In the age of LLMs, standardized repos for your codebases can really affect performance. Luckily, ChatGPT can one-shot generating these which is why the code is not provided.

In the age of LLMs, standardized repos for your codebases can really affect performance. Luckily, ChatGPT can one-shot generating these which is why the code is not provided. This is a public list of ideas to help brainstorm things you can do to standardize your repository format.
Imagine you were dropped in a huge repo which you now have to take ownership of the code. When you first do that, you can do as many small refactors as possible to clean up the code to a better state and then going into the refactors of substance.
If you think something should be on this list, please submit a PR to add it!
”You can not pay people enough to accurately review verbose code, and believe me we have tried”
- Some due who worked at Jane Street
clang-tidy
to lint your repos and automatically fix themclang-format
to ensure code is formatted properlyruff format
to format python coderuff check --fix
to run a linter over your python code
C++ Advice
- Replacing
#ifndef
with#pragma once
in all header file (yes, I know#pragma once
is non-standard)
ROS Specific Advice
- Ensure a ROS packages’s name (defined in the
package.xml
) is the same as the folder name. - Ensure all of your gtest test cases are of the format
test_<test_case_name>
instead of<test_case_name>_test
. - Ensure if a file contains
class MyNode : public rclcpp::Node
that it must end in_node
- Replacing
this->
for the rclcpp core functions with a regexcreate_subscription
create_publisher
get_clock
create_timer
get_logger
declare_parameter
- Use a CMakeLists toolchain instead of using
--cmake-args
for colcon - Using the
seconds
utility function instead of doingbestpos_msg.header.stamp.sec + bestpos_msg.header.stamp.nanosec * 1e-9
you dorclcpp::Time(bestpos_msg.header.stamp).seconds();
- Replacing
get_clock().now()
withnow()
- Replacing the
.set__<var_name>()
with=
syntax - Move inline definitions to out of line definitions
Bash
- Use
set -euo pipefail
in all your bash scripts
Docker
- Use a builder Dockerfile to minimize package size runtimes
- Use read-only services when using Dockerfiles
General Code Cleanliness
- Make sure it is
README.md
instead ofreadme.md
or something derivative - Specify the language ```python` in markdown code blocks
Breaking down my personal development setup
Stay in touch
Subscribe to my RSS feed to stay updated
Have any questions
Feel free to contact me! I will answer any and all inquires