Command Palette

Search for a command to run...

Назад к скиллам
скилл № 38454

add-rule

Turns a rule this project's code must keep (only one module may read a database, only one service may create an access proof, no controller may call a lookup…

БесплатноБез исполняемых скриптов
a-pavithraaот a-pavithraa★ 82 звезды на GitHub

Установить add-rule в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Add a rule

The harness's CodeRulesTests holds rules every Spring Boot project shares. A rule that belongs to this project, such as "only caller reads the patient database" or "only AccessDecisions makes an AccessGrant", goes in its own test, so the build fails on the next break instead of a reviewer having to remember it.

When asked to find rules nobody wrote down, list candidates before writing any test. A candidate is a pattern every current caller follows: one package builds a type, one module asks for a bean, no controller touches a lookup. Give each one its evidence (the callers that follow it, a fix in git log that restored it, a decision record that implies it) and any code that already breaks it, which may be a bug. The user picks which ones become rules; take each through the steps below. A rule about values rather than structure, such as "a balance never goes negative", is a property test, not an ArchUnit rule: use writing-springboot-tests.

  1. Write the rule in one sentence, with its reason, and agree it with the user. Add that sentence to the Failures list in REVIEW.md, since a reviewer must still catch what the test can't see.
  2. Pick the shape that fits. Each is one ArchUnit rule on the production classes:
    • Only package P may construct type T. For an access proof, a grant, a scope, or a token that other modules receive but must never make. noClasses().that().resideOutsideOfPackage("{{BASE_PACKAGE}}.access..").should().callConstructor(Grant.class, ...). Spring Modulith lets any module use a type a published method returns, so this is the only thing that stops a module building its own proof. Also cover static factories: .orShould().callMethod(Grant.class, "of", ...).
    • Only package P may ask for bean B. For a datasource, a client or a connection picked by bean name. Check every way Spring injects it: @Qualifier("name") on a parameter, field, constructor or method; an annotation that carries @Qualifier itself; @Resource(name = ...); a setter @Resource named after the bean; and a bare parameter or field named after the bean, which Spring matches when no candidate is @Primary. ArchUnit doesn't read parameter names; parameter.getOwner().reflect() does, since Boot compiles with -parameters.
    • No class of kind K may depend on type or package X. For a lookup that trusts its input, a vendor type that must stay in one module, or a module's named interface meant for background jobs only. noClasses().that().areMetaAnnotatedWith(Controller.class).should().dependOnClassesThat(...).
  3. Create src/test/java/{{BASE_PATH}}/<Rule>ArchRuleTests.java. The name ends in ArchRuleTests, which no domain test takes by accident: the harness's guard refuses edits to such a file, CI fails a pull request that changes it without the harness-rule-change label, and the Stop hook runs it with the other fast gates. Import the classes once, with ImportOption.Predefined.DO_NOT_INCLUDE_TESTS, and give the rule a because that says what to do instead.
  4. Prove the rule fires. A rule that matches nothing passes forever. Put a class that breaks it under src/test/java/{{BASE_PATH}}/archfixture/, one per way of breaking it, and add a second test that imports only those fixtures with new ClassFileImporter().importClasses(...) and asserts rule.evaluate(fixtures).getFailureReport().getDetails() names each one. For the bean-name shape, that is seven fixtures: constructor qualifier, field qualifier, @Bean method parameter, name only, @Resource, composed qualifier, setter.
  5. Run {{VERIFY}}. If existing code breaks the rule, don't weaken it: list the breaks for the user, who decides between fixing them in this change and recording them in docs/ as known drift, with a test that passes while the break exists and a comment saying to turn it around once fixed.
  6. If the rule guards a decision, add the test's name to that decision's record, so a reader of the decision finds its guard.

Don't put a project rule in CodeRulesTests: the harness replaces that file on a rerun. Don't express a rule only in AGENTS.md or a comment: agents follow a build failure every time and a sentence most of the time.

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл add-rule?

Turns a rule this project's code must keep (only one module may read a database, only one service may create an access proof, no controller may call a lookup that trusts its input) into an ArchUnit test the build enforces and the harness protects. Use when the user states such a rule, when a review finds a break of one, when a decision record says "always" or "never" about code, or when the user asks to find the rules the code relies on but nothing enforces.

Как установить скилл add-rule?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл add-rule запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить add-rule с