Prescriptive Ruby style.
Construction and robustness
- Robustness lives at the class interface, not the instance: the initializer (
new) is strict and records inputs as-is; the class interface is the forgiving perimeter (coercion, liberal acceptance, uniform returns), and it can sit at increasing distance from the core — abuildconstructor, or a coercion function on an outer module. buildis the normalizing constructor;newis the strict initializer. A supertype acting as a factory of its subtypes may call a subtype'snewdirectly once it holds strict-form input.
Naming and signatures
- Never put a preposition in a method name — name the action (
import, notimport_from). - Optional parameters default to
nilin the signature; assign the real default in the body (||=, or.nil?for a settable payload that may be legitimately falsy; don't default an argument you only delegate). - A positional-argument default is written tight —
namespace=Object, no spaces.
Structure
- Don't inline a method-call result as an argument — bind it to an explaining variable first.
- Include the primary domain mixin before infrastructure mixins.
Command: lib-report (classify lib/ by role, construct, method style, API currency, error taxonomy, idioms).
code/ groups by programming language and is not a package; code/ruby is the package. Includes foundation, language.
code/ruby → foundation, language
Install with git subtree — the files land in your project's agent/rules/ tree, committed alongside your code and read at session start:
git subtree add --prefix agent/rules/code/ruby https://github.com/eventide-project/agent-norms-code-ruby.git master --squash
git subtree pull --prefix agent/rules/code/ruby https://github.com/eventide-project/agent-norms-code-ruby.git master --squash
It includes foundation and language — install those too, or run sh agent/rules/code/ruby/install-dependencies.sh from your project root.
Refresh from upstream periodically to pull the latest rules:
git subtree pull --prefix agent/rules/code/ruby https://github.com/eventide-project/agent-norms-code-ruby.git master --squash