Note: Code review rules is currently in beta. If you would like to use this feature, please contact us at support@macroscope.com.
Setting Up macroscope.md Files
To set up your custom rules, add a macroscope.md file to the root directory of any folder(s) you’d like to set custom rules for.
For repository-wide rules, create a file at the root of your repository.For folder-level rules, create a file in the root of the folder you’d like the rules to apply to.
macroscope.md file, list out the best practices relevant to that part of your codebase. Think of these as the idioms and conventions that capture how you want code to be written — from common patterns surfaced during reviews by more experienced developers, to reminders about helpful utilities that are often overlooked. To help you get started, we’ve shared some examples from our own use below.
During code review, Macroscope will:
- Run a separate CheckRun on the Pull Request, that’s focused on the rules defined in your
macroscope.mdfile(s). - Leave inline comments pointing to the exact code that violates a rule.
- Reference the specific rule from your guidelines in each comment.
macroscope.md files can always be updated as you see fit.
You can create different
macroscope.md files in different folders if folders of your repository follow different conventions.For example, if you have separate backend and frontend folders, you can create separate backend/macroscope.md and frontend/macroscope.md files to set different rules for each folder.Learn about folder-level rule configuration.Example Rules
Below are a few common use cases:Style
e.g.
To improve clarity and maintain consistent scoping, errors should be if-scoped only when all declared variables are used exclusively within that scope.Logging Guidelines
e.g.
All logs must be structured in JSON format.Typos
e.g.
Literal and formatted strings that might be displayed to the user should be free of typos.Security
e.g.
File Systems should always be accessed using a rooted filesystem operation.Example macroscope.md File
Folder-Level Rule Configuration
If you want to create specific rules for specific subfolders within a repository, you can create files namedmacroscope.md in each of those folders.
Multiple macroscope.md files are useful when:
- You have different languages and frameworks within the same repository.
- You want distinct rulesets for distinct parts of your project (e.g.
backend/vs.frontend/subfolders). - You have team-specific guidelines that don’t apply globally.
macroscope.md files it finds along the way.
If you want to stop inheritance at a certain point (e.g. in a multi-language monorepo), name that file macroscope_root.md. If Macroscope encounters a file named macroscope_root.md, it stops climbing, meaning that no rules from parent folders above that point will be applied.
Otherwise, Macroscope will merge the macroscope.md rules it finds as it moves up the folder structure.
macroscope_root.md files are optional. If you don’t include any, rules will be inherited from parent folders.