Writing config files server owners don't hate.
Config is documentation. Here's how we structure ours so a brand-new admin can stand up rb-mechanic without ever opening the wiki.
We've been told, by more than one customer, that the thing they like best about RB Studios scripts is the config file. This is a deeply weird piece of feedback, because the config file should be the least interesting thing about a piece of software. It's a list of variables.
But it's not, really. A config file is the first thing a server owner reads about your product. It is documentation. It is onboarding. It is the place where your assumptions meet their server, and either you're going to be helpful about that meeting or you're going to be a pain.
Here's how we structure ours.
The opening comment
Every config file opens with a banner comment that answers three questions:
- What is this file for? One sentence.
- What happens if I leave it alone? One sentence.
- Where do I go for help? One link.
-- rb-mechanic / config.lua
--
-- All tunables for the player-run mechanic system.
-- Out of the box, this config produces a fully working shop on
-- ESX, QBCore, or QBox with auto-detection. No edits required.
--
-- Stuck? https://docs.rb-studios.dev/rb-mechanicThat's it. Server owners who have read this exact paragraph before will skip it. Server owners who haven't will know within ten seconds whether they need to touch this file at all.
The first section is the one they need
Below the banner, the first section is the section the median server owner will actually edit. For rb-mechanic, that's framework, currency type, and job name. Everything else — payout curves, parts catalogues, hooks — comes after.
We've watched server owners open our config files, find the three things they need in the first ten lines, and close the file. That is the correct outcome. The config file is not a museum tour. It's a control panel. The most-used controls go on top.
Comments answer "why," not "what"
A bad config comment:
-- The base price for a tier-1 job
Config.tier1Price = 250This comment tells me what I can already read. It is noise.
A good config comment:
-- Tier 1 jobs are intended as a tutorial; we recommend keeping this
-- low enough that players don't feel "stuck" before they learn the
-- system. Bumping this above 400 makes higher tiers feel underpaid.
Config.tier1Price = 250This comment tells me what I cannot read from the value. It tells me the intent, so when I change the value, I'm changing it in the right direction.
Not every line deserves a comment like this. Most don't. But the lines that are commented should earn it.
Group by use case, not by data type
The wrong way to organize a config:
-- ====== Booleans ======
Config.enableNotifications = true
Config.enableTowing = true
-- ====== Numbers ======
Config.tier1Price = 250
Config.towingCost = 75
-- ====== Strings ======
Config.framework = "qbox"
Config.locale = "en"This is convenient for the engineer who wrote it. It is hostile to the server owner who reads it. Nobody opens a config file thinking "let me adjust some booleans." They open it thinking "let me enable towing."
Group by what the server owner is trying to do:
-- ====== Framework ======
Config.framework = "qbox"
Config.locale = "en"
-- ====== Towing ======
Config.enableTowing = true
Config.towingCost = 75
-- ====== Jobs ======
Config.tier1Price = 250Migrations are part of the contract
When we change a config shape, we ship a migrator that runs once at boot. The migrator:
- Detects the old shape.
- Prints a clear, single-line warning describing what's about to change.
- Rewrites the file in place, preserving comments.
- Backs up the original to
config.lua.bak.<timestamp>.
This is a non-trivial amount of engineering work. It is also the difference between an upgrade being "edit the changelog" and an upgrade being "edit the changelog at 2am while the server is down."
If your config shape is going to change, you owe your users a migrator. If you can't ship one, you owe them at least a very loud comment at the top of the file pointing them at the changelog entry.
What to skip
You don't have to do everything. The smallest version of this advice that pays for itself:
- Open with a banner that says what the file is for.
- Put the most-edited section on top.
- Comment intent, not values.
- Ship a migrator when you change shape.
That's a one-evening cleanup for a config you already have, and it will make new admins onto your server measurably less miserable.
Make it easy to be a server owner. They're the ones doing the hard work.