service-guard — for Claude Code service-guard, microservices-simulator, community, for Claude Code, ide skills, service-layer guard, precondition checks, data consistency, Layer 3 service-layer guards, aggregate mutations

v1.0.0

关于此技能

适用场景: Perfect for Development Agents needing advanced service-layer security and data consistency checks. 本地化技能摘要: Add a Layer 3 service-layer guard to an existing service. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

功能特性

Implement precondition checks using Layer 3 service-layer guards
Read from the database to evaluate preconditions
Throw exceptions before aggregate mutations are applied
Ensure data consistency across applications
Integrate with existing services and repositories

# 核心主题

socialsoftware socialsoftware
[5]
[3]
更新于: 3/26/2026

Killer-Skills Review

Decision support comes first. Repository text comes second.

Reference-Only Page Review Score: 8/11

This page remains useful for teams, but Killer-Skills treats it as reference material instead of a primary organic landing page.

Original recommendation layer Concrete use-case guidance Explicit limitations and caution
Review Score
8/11
Quality Score
33
Canonical Locale
en
Detected Body Locale
en

适用场景: Perfect for Development Agents needing advanced service-layer security and data consistency checks. 本地化技能摘要: Add a Layer 3 service-layer guard to an existing service. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

核心价值

推荐说明: Empowers agents to enforce preconditions and validate aggregate mutations using custom repository interfaces and error constants, ensuring data integrity and security within microservices architectures, specifically leveraging Java and UoW transactions.

适用 Agent 类型

适用场景: Perfect for Development Agents needing advanced service-layer security and data consistency checks.

赋予的主要能力 · service-guard

适用任务: Implementing service-layer guards for existing services
适用任务: Validating preconditions before aggregate mutations
适用任务: Throwing exceptions for inconsistent data or security breaches

! 使用限制与门槛

  • 限制说明: Requires knowledge of Java and microservices architecture
  • 限制说明: Limited to services with existing custom repository interfaces
  • 限制说明: Must adhere to specific naming conventions for error constants

Why this page is reference-only

  • - Current locale does not satisfy the locale-governance contract.
  • - The underlying skill quality score is below the review floor.

Source Boundary

The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.

评审后的下一步

先决定动作,再继续看上游仓库材料

Killer-Skills 的主价值不应该停在“帮你打开仓库说明”,而是先帮你判断这项技能是否值得安装、是否应该回到可信集合复核,以及是否已经进入工作流落地阶段。

实验室 Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

常见问题与安装步骤

以下问题与步骤与页面结构化数据保持一致,便于搜索引擎理解页面内容。

? FAQ

service-guard 是什么?

适用场景: Perfect for Development Agents needing advanced service-layer security and data consistency checks. 本地化技能摘要: Add a Layer 3 service-layer guard to an existing service. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

如何安装 service-guard?

运行命令:npx killer-skills add socialsoftware/microservices-simulator。支持 Cursor、Windsurf、VS Code、Claude Code 等 19+ IDE/Agent。

service-guard 适用于哪些场景?

典型场景包括:适用任务: Implementing service-layer guards for existing services、适用任务: Validating preconditions before aggregate mutations、适用任务: Throwing exceptions for inconsistent data or security breaches。

service-guard 支持哪些 IDE 或 Agent?

该技能兼容 Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer。可使用 Killer-Skills CLI 一条命令通用安装。

service-guard 有哪些限制?

限制说明: Requires knowledge of Java and microservices architecture;限制说明: Limited to services with existing custom repository interfaces;限制说明: Must adhere to specific naming conventions for error constants。

安装步骤

  1. 1. 打开终端

    在你的项目目录中打开终端或命令行。

  2. 2. 执行安装命令

    运行:npx killer-skills add socialsoftware/microservices-simulator。CLI 会自动识别 IDE 或 AI Agent 并完成配置。

  3. 3. 开始使用技能

    service-guard 已启用,可立即在当前项目中调用。

! 参考页模式

此页面仍可作为安装与查阅参考,但 Killer-Skills 不再把它视为主要可索引落地页。请优先阅读上方评审结论,再决定是否继续查看上游仓库说明。

Upstream Repository Material

The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.

Upstream Source

service-guard

本地化技能摘要: Add a Layer 3 service-layer guard to an existing service. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

SKILL.md
Readonly
Upstream Repository Material
The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.
Supporting Evidence

Add Service-Layer Guard: $ARGUMENTS

You are adding a new Layer 3 service-layer guard to an existing service in applications/quizzes.

A service-layer guard is a precondition check that reads from the database and throws an exception before any aggregate mutation is applied. It runs inside the same UoW transaction as the operation.

The guard must only read the service's own aggregate type. If a foreign aggregate must be read to evaluate the precondition, use a Layer 5 saga step instead (/inter-invariant or a named step in the functionality). Consult docs/concepts/consistency-enforcement.md if uncertain.


Step 0 — Parse the arguments

From $ARGUMENTS identify:

  • ServiceName: the service class to modify (e.g. ExecutionService, TournamentService)
  • Operation method: the service method receiving the guard (e.g. enrollStudent, createCourseExecution)
  • Precondition: what must hold before the mutation is allowed (e.g. "user must be active", "no duplicate acronym/term")

Step 1 — Read existing code

Before writing anything, read:

  1. The service class microservices/<aggregate>/service/<Service>.java — focus on the target operation method and how other guards in the same class are structured
  2. The custom repository interface microservices/<aggregate>/aggregate/<Aggregate>CustomRepository.java (if it exists) and its implementations:
    • microservices/<aggregate>/aggregate/sagas/<Aggregate>SagaRepository.java
    • microservices/<aggregate>/aggregate/causal/<Aggregate>CausalRepository.java
  3. QuizzesErrorMessage.java — existing error constants
  4. The closest test class under src/test/groovy/.../sagas/coordination/<aggregate>/

Step 2 — Design the guard

Decide:

  • Guard placement: immediately before the copy-constructor call or registerChanged(), never after a mutation has been applied
  • Repository query needed: can the check be done on the aggregate already loaded by the operation, or does it need a separate query (e.g. findAllAggregateIds(), a custom finder)?
    • Prefer reusing an already-loaded aggregate over an extra DB read
    • If a new query is needed, add it to the custom repository interface and both implementations (Sagas + TCC)
  • Error constant name: follow the convention:
    • CANNOT_<OP>_WHEN_<CONDITION> (e.g. CANNOT_ENROLL_WHEN_INACTIVE)
    • DUPLICATE_<ENTITY> (e.g. DUPLICATE_COURSE_EXECUTION)
    • INACTIVE_<ENTITY> (e.g. INACTIVE_USER)
    • Reuse an existing constant if one already expresses the same rule

Document the decision in a brief comment before writing code.


Step 3 — Add the guard check

Inside the service method, add the guard before any aggregate mutation, with an inline label comment:

java
1// GUARD_NAME — <one-line description of what is being checked> 2if (<precondition violated>) { 3 throw new QuizzesException(<ERROR_CONSTANT>, <relevant ids...>); 4}

Real examples from ExecutionService.java:

java
1// DUPLICATE_COURSE_EXECUTION — reject creation if acronym+term already exists 2if (existing.getAcronym().equals(courseExecutionDto.getAcronym()) 3 && existing.getAcademicTerm().equals(courseExecutionDto.getAcademicTerm())) { 4 throw new QuizzesException(DUPLICATE_COURSE_EXECUTION, 5 courseExecutionDto.getAcronym(), courseExecutionDto.getAcademicTerm()); 6} 7 8// INACTIVE_USER — block enrollment of inactive users 9if (!courseExecutionStudent.isActive()) { 10 throw new QuizzesException(INACTIVE_USER, courseExecutionStudent.getUserAggregateId()); 11}

Step 4 — Add repository query (if needed)

If the guard requires a DB query not already available:

  1. Add the method signature to the custom repository interface:

    java
    1// <Aggregate>CustomRepository.java 2List<Integer> findAggregateIdsByXxx(Integer someId);
  2. Implement it in both the Sagas and TCC repository classes with the same logic.

If the guard can be evaluated on an aggregate already loaded by the operation, skip this step.


Step 5 — Add error message constant

In QuizzesErrorMessage.java, add the new constant if it does not already exist:

java
1CANNOT_<OP>_WHEN_<CONDITION>("Cannot <operation>: <human-readable reason>"),

Step 6 — Write tests

Add test cases to the relevant *Test.groovy under src/test/groovy/.../sagas/coordination/<aggregate>/.

Cover at minimum:

ScenarioExpected outcome
Precondition satisfiedOperation succeeds
Precondition violatedQuizzesException with the correct error code
Boundary / edge casesCorrect behaviour

Run with:

bash
1mvn clean -Ptest-sagas test -Dtest=<YourTestClass>

Checklist before finishing

  • Guard check added before any mutation in the service method, with inline label comment
  • Repository query added to custom repository interface + both implementations (Sagas + TCC), if a new query was needed
  • Error message constant added to QuizzesErrorMessage.java (or existing one reused)
  • Tests written and passing

相关技能

寻找 service-guard 的替代方案 (Alternative) 或可搭配使用的同类 community Skill?探索以下相关开源技能。

查看全部

openclaw-release-maintainer

Logo of openclaw
openclaw

本地化技能摘要: 🦞 # OpenClaw Release Maintainer Use this skill for release and publish-time workflow. It covers ai, assistant, crustacean workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

333.8k
0
AI

widget-generator

Logo of f
f

本地化技能摘要: Generate customizable widget plugins for the prompts.chat feed system # Widget Generator Skill This skill guides creation of widget plugins for prompts.chat . It covers ai, artificial-intelligence, awesome-list workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf

149.6k
0
AI

flags

Logo of vercel
vercel

本地化技能摘要: The React Framework # Feature Flags Use this skill when adding or changing framework feature flags in Next.js internals. It covers blog, browser, compiler workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

138.4k
0
浏览器

pr-review

Logo of pytorch
pytorch

本地化技能摘要: Usage Modes No Argument If the user invokes /pr-review with no arguments, do not perform a review . It covers autograd, deep-learning, gpu workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

98.6k
0
开发者工具