Agent-Enhanced Development · Chapter 3
Naming that reads like a sentence
You open the file your agent wrote last week and can't tell what it does. Here is one file, read four ways, and nobody rewrites anything. Scroll, or press a step.
The code you would normally write. Properties for what it needs, one method per step, and comments in the place Crystal reads as documentation.
Shrink the bodies. When we plan, we think in the big picture: what we need, and the steps we take. The bodies are detail. Fold them and the plan is what is left.
Hide the syntax and read it. Take away def, end, colons, and underscores. What remains is a list of what it needs and a list of what it does, in plain words.
It becomes the document. The comments were written where Crystal reads them as documentation, so the same file is the help page: what this needs, the policy, how it runs.
Now switch to the second tab and take it through the same four steps. The plan lived inside a method body, so folding erased it, and there was nothing written where documentation is read.
What this chapter settles
Naming conventions carry the meaning, so every window that holds the name holds the meaning.
These are the AED naming conventions for AI coding agents: the rules your agent applies when it writes or renames a file for you, and the rules a teammate's agent can read back.
- Attributes are short statements of purpose.Which name? Whose email? The name answers before anyone has to ask.
name→ first_nameemail→ email_address - Collections announce themselves.Active only, and a list: two facts the old name kept to itself.
subscriptions→ list_of_all_active_subscriptions - Booleans are questions.A yes-or-no name reads as the condition it guards.
enterprise→ is_this_an_enterprise_customerpayment_method_present→ has_a_valid_payment_method - Classes are namespaced by feature and state the process.The name is the sentence the owner would say.
LateFeeService→ Billing::ApplyLateFee - Methods say what they do, and perform reads like the plan.One named step per line, each step its own private method.
process→ performcalculate_fee→ charge_the_late_fee - A property with a type and a default is a requirement with a policy.Required means no default. The default is the company's number.property grace_period_in_days : Int32 = 30
- Doc comments go where Crystal reads them.Directly above the class, property, or method. Group headings are comments set apart by a blank line. That is why step four exists.# Days past due before any fee applies.
property grace_period_in_days : Int32 = 30 - Files match the class.Snake case of the class, in a folder named for the namespace.billing/apply_late_fee.cr
From the canon
The customer class, before and after. Drag the divider.
The name before could have been a first name, a full name, or a company. subscriptions did not say it held only the active ones. The after file says both, and says whether this is an enterprise customer, which the sales team needed and the agent had no way to know.
Why it matters to the agent
A model reads through a sliding window. Put the meaning inside the name.
days_late means something only if the reader already knows the unit and the subject. how_many_days_late carries both, so every window that holds the name holds the meaning.
Reading with an agent? Hand it the machine edition of this chapter. The source is chapter 02 of the canon.