Skillquality 0.46

houtu-dependencies

houtu-dependencies enterprise-grade Spring Cloud microservice foundational framework complete usage guide. GroupId is io.github.lujiafa, covering unified response, exception handling, parameter parsing, session authentication, permission control, signature verification, anti-repl

Price
free
Protocol
skill
Verified
no

What it does

Houtu Framework — AI Agent Coding Guide

houtu-dependencies is an enterprise-grade foundational framework for Spring Boot / Spring Cloud microservices that implements "Activate-on-import" via the Spring Boot Starter mechanism, allowing developers to focus entirely on business logic.

Repository: https://github.com/lujiafa/houtu-dependencies Git Branches: 3.5.2, 3.5.1, 3.5.0, 2.7.3, 2.7.2, 2.7.1 (branch name = version)


Core Principles

  1. Activate-on-import — Capabilities are automatically enabled after adding a starter dependency; no @Enable annotations or manual configuration needed
  2. Annotation-driven — Control behavior through annotations (@Lock, @CheckSession, @SecurityWatch...); do not hand-write interceptors/AOP
  3. Framework-first — For capabilities already encapsulated by the framework, use the framework approach by default instead of native Spring; defer to user when they explicitly request the native approach
  4. Convention over configuration — Follow framework defaults; only override when customization is needed
  5. Version-aware — Package paths, API names, and configuration approaches differ across versions; the version must be confirmed before generating code

Code Generation Workflow (must be executed in order)

Step 1: Detect Version & Dependencies → Step 2: Identify Scenario → Step 3: Load Module Reference → Step 4: Generate Code → Step 5: Verify

Step 1 — Detect Version & Dependencies

The version must be determined before generating any code, and the BOM must be imported.

Read the project build file (pom.xml or build.gradle / build.gradle.kts) and determine in the following order:

1a. houtu already imported — The build file contains houtu-dependencies or spring-cloud-houtu:

  • Read the version number directly to determine the version, proceed to Step 2
  • Multi-module projects: The BOM is usually declared in the root pom.xml or root build.gradle under dependencyManagement; submodules inherit it and do not need to add it again

1b. Not imported but user explicitly wants houtu — The user mentions "use houtu", "integrate houtu", "use houtu-dependencies", etc.:

  • Confirm the version (ask the user or infer from the project's Spring Boot version: 3.x3.5.2, 2.x2.7.3)

  • Proactively add the BOM to the build file:

    Maven (pom.xml):

    <!-- Base module BOM (required) -->
    <dependency>
        <groupId>io.github.lujiafa</groupId>
        <artifactId>houtu-dependencies</artifactId>
        <version>${version}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    

    Gradle (build.gradle / build.gradle.kts):

    // Base module BOM (required)
    implementation platform("io.github.lujiafa:houtu-dependencies:${version}")
    

    If the task involves Spring Cloud modules (Feign, canary routing, Sentinel, service discovery), also add:

    <!-- Maven: Spring Cloud enhancement module BOM -->
    <dependency>
        <groupId>io.github.lujiafa</groupId>
        <artifactId>spring-cloud-houtu</artifactId>
        <version>${version}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    
    // Gradle: Spring Cloud enhancement module BOM
    implementation platform("io.github.lujiafa:spring-cloud-houtu:${version}")
    
  • Load references/quick-start.md to complete first-time setup

1c. Cannot determine — Ask the user, or default to the latest version 3.5.2

After determining the version, immediately load the corresponding version reference file (references/v{version}.md) to obtain:

  • The correct package prefix (io.github.lujiafa.houtu.*)
  • The correct namespace (jakarta.* or javax.*)
  • The correct configuration path (spring.data.redis.* or spring.redis.*)
  • Dependency versions (Spring Boot, Spring Cloud, Redisson, etc.)

Step 2 — Identify Scenario & Select Module

Analyze the coding task — not only match the user's explicit requirements, but also proactively identify scenarios that can be enhanced based on business logic semantics (see the "Business Scenario Enhancement Guide" below).

Select the module reference files to load from the table below (a single task usually involves multiple modules):

Coding TaskModuleReference File
New microservice / First-time setupreferences/quick-start.md
Write Controller / Unified response / Exception handling / Parameter bindinghoutu-webreferences/module-web.md
Auth / Permissions / Session / Signing / Anti-replayhoutu-web-securityreferences/module-security.md
Distributed lock / Rate limitinghoutu-cachereferences/module-cache-lock.md
Database field encryptionhoutu-data-securityreferences/module-data-security.md
Request access logginghoutu-access-logreferences/module-access-log.md
Canary routing / Feign / Sentinel / Service discoveryspring-cloud-houtu-*references/module-cloud.md
Config value decryptionhoutu-corereferences/module-config-decrypt.md
API documentationhoutu-web-swaggerreferences/module-swagger.md
Crypto / Signing / Hash / JSON / HTTP client utilitieshoutu-utilsreferences/module-utils.md
Monitoring / Metrics / Observabilityhoutu-actuatorreferences/module-actuator.md
Async / Scheduled tasks / Cross-thread context propagationhoutu-corereferences/module-concurrent.md

Example: When the user says "write a payment endpoint", you should simultaneously identify: houtu-web (Controller response) + houtu-web-security (login authentication) + houtu-cache (@Lock for concurrency protection + @CheckRepeatRequest for anti-replay) + houtu-access-log (audit logging for financial operations), rather than just writing a bare Controller.

Step 3 — Load Module Reference Files

Load the corresponding module reference files before writing code. Each file is a complete recipe: Maven dependency → Required configuration → import → Code patterns → Practices to avoid by default → Internal behavior.

If the task involves multiple modules, load all relevant files.

Step 4 — Generate Code (with automatic dependency management)

  1. Check and add missing Starter dependencies — Check whether the modules required for the current scenario are already imported in the <dependencies> of pom.xml; if not, proactively add them (no version needed, managed by BOM). Similarly, if the scenario involves spring-cloud-houtu-* modules, ensure the spring-cloud-houtu BOM is already in <dependencyManagement>
  2. Use the correct package prefix and imports from the version file
  3. Use the API patterns and code examples from the module files
  4. Check the Anti-Pattern Checklist — Confirm that native Spring approaches are not used to duplicate functionality
  5. Use the framework's Model base classes (BaseForm, BaseVO, BaseDTO, PageForm, PageDataVO, etc.)

Step 5 — Verify

For uncertain APIs, verify by reading source code via git show <branch>:<path>:

git show <branch>:<file-path>
# Example:
git show 3.5.2:houtu-cache/src/main/java/io/github/lujiafa/houtu/lock/annotation/Lock.java

Business Scenario Enhancement Guide (Proactively identify, apply when appropriate)

When writing business code, do not wait for the user to explicitly specify framework features; instead, proactively identify applicable framework capabilities based on the semantics of the business logic and naturally integrate them into the code. Below are common business scenarios and their mapping to framework enhancements:

Interface Layer (Controller)

Business CharacteristicFramework Capability to EnhanceDescription
Any Controller methodResponseData<T> + BaseForm/PageFormBasic convention; all endpoints must follow
Requires login to access@CheckSessionAdd by default for user-related endpoints
Role-based permissions (e.g., admin vs. regular user)@RequiresRole / @RequiresPermissionDetermine from business description; no need for user to specify each one
Endpoint has audit/traceability requirements@AccessLogProactively add for financial, order, or sensitive operations
Endpoint receives user-input rich text/comments@NotXssShould be added to all user-editable text fields
List query (with pagination)PageForm + PageDataVO<T>Apply when "list", "query", "pagination" intent is identified

Business Layer (Service)

Business CharacteristicFramework Capability to EnhanceDescription
Concurrent write operations (e.g., placing orders, deducting inventory, deducting balance)@LockProactively add when concurrency-sensitive operations like "payment", "inventory", "balance" are identified
Submission operations (e.g., placing orders, payments, transfers)@CheckRepeatRequestProactively add for write operations with idempotency requirements
Calling external HTTP APIs (e.g., payment callbacks, third-party integrations)HttpClientsDo not use RestTemplate/WebClient
Object conversion (Entity → VO / Form → DTO)BeanUtils.smartCopyPropertiesDo not use Spring BeanUtils
JSON operationsJsonUtilsDo not create your own ObjectMapper
High-concurrency hotspot operations (e.g., flash sales)RateLimiterApply when "rate limiting", "flash sale", "rush purchase" intent is identified
Async/scheduled tasks needing session or context accessFramework auto-propagation (TransferThreadPoolTaskExecutor)@Async, @Scheduled, CompletableFuture automatically inherit parent thread's SessionContext, HintContext, etc.; no manual handling needed

Data Layer

Business CharacteristicFramework Capability to EnhanceDescription
Storing sensitive fields like phone numbers, ID cards, bank accounts@SecurityWatch + @SecurityParamProactively suggest when field names contain phone/mobile/idCard/bankAccount, etc.
Database passwords, API Keys in config fileshoutu-core config decryptionProactively suggest when password, secret, key config items are identified

Microservice Layer

Business CharacteristicFramework Capability to EnhanceDescription
Inter-service calls@AutoFeignDo not hand-write FeignClient + RequestInterceptor
Canary/AB testing/multi-tenant routingHintContextApply when "canary", "canary release", "route specific users" intent is identified
External system callbacks (e.g., payment notifications)@CheckSign + @CheckRepeatRequestCallback scenarios typically require both signature verification and anti-replay

Application Principles

  1. Do not over-enhance — Only apply when business semantics truly match; do not pile on annotations just to showcase features. For example, internal admin tools may not need @AccessLog; simple queries do not need @Lock
  2. Do not miss critical enhancements — Scenarios involving finance, security, or concurrency must have corresponding capabilities applied; this is the core value of the framework
  3. Progressive adoption — When users first integrate, ensure basic capabilities (houtu-web) first; then gradually introduce other modules based on actual scenarios in subsequent coding
  4. Add dependencies on demand — When using a module's capabilities, first check whether the Starter is already imported in pom.xml; if not, proactively add it

Anti-Pattern Checklist (Agent follows by default during autonomous coding; defers to user when explicitly requested)

Scenario⚠️ Avoid by Default✅ Framework Approach (Preferred)
Endpoint authImport spring-security or hand-write Filter to verify token@CheckSession + @RequiresRole / @RequiresPermission
Unified responseCustom Result/Response class or wrap with ResponseEntityReturn ResponseData<T> or EmbedResponseData
Exception handlingHand-write @ControllerAdvice + @ExceptionHandlerThrow BusinessException; framework handles automatically
Parameter validation responseManually catch BindException and formatFramework handles automatically, returns {code:30, message:"..."}
Database field encryptionHand-write TypeHandler or manually encrypt/decrypt in Service layer@SecurityWatch + @SecurityParam annotations
Distributed lockHand-write Redis SETNX or Redisson calls@Lock annotation or LockSupport
Feign callsHand-write RequestInterceptor to pass headersFramework auto-propagates; use @AutoFeign to publish interfaces
Request loggingHand-write Filter/Interceptor to record logs@AccessLog annotation
Signature verificationHand-write signature verification interceptor@CheckSign annotation
Anti-replayHand-write Redis idempotency check@CheckRepeatRequest annotation
Load balancingHand-write LoadBalancer strategyUse HintContext + configure weights
Swagger docsManually import springdoc/springfox and configureImport houtu-web-swagger starter
Rate limitingHand-write Redis Lua rate limiting scriptUse RateLimiter
Symmetric/asymmetric encryptionManually import BouncyCastle or hand-write crypto utility classesUse SM4Utils / AESUtils / RSAUtils / SM2Utils, etc.
JSON serializationManually create ObjectMapper instancesUse JsonUtils
HTTP clientManually create RestTemplate or HttpClientUse framework's auto-configured HttpClients
Config value decryptionHand-write EnvironmentPostProcessor or manually decrypt at startupUse houtu-core's decrypt configuration
Monitoring metricsHand-write Micrometer MeterBinder to collect endpoint metricsImport houtu-actuator starter for automatic collection
Async thread context propagationHand-write TaskDecorator or manually set/get context in child threadsFramework auto-replaces with TransferThreadPoolTaskExecutor; @Async/CompletableFuture/@Scheduled auto-propagate SessionContext, HintContext, etc.

Model Base Class Hierarchy

Business code should inherit from the framework-provided base classes:

BaseResponseData<T>        (interface: getCode(), getMessage(), getData())
├── ResponseData<T>        (standard JSON response with code/message/data)
└── EmbedResponseData      (extends LinkedHashMap, flattened response)

BaseForm                   (request form base class, implements Serializable)
└── PageForm               (pagination request, contains currentPage/pageSize)

BaseDTO                    (data transfer base class, implements Serializable)
├── PageQueryDTO           (pagination query DTO, contains currentPage/pageSize)
└── PageDataDTO<R,V>       (pagination data DTO, contains records/totalRecords/totalPages)

BaseVO                     (view object base class, implements Serializable)

PageDataVO<V> extends BaseDTO  (pagination response, contains records/totalRecords/totalPages/currentPage/pageSize)
└── PageDataExtVO<D,V>         (pagination response + extra data field D data, e.g., paginated list with summary statistics)

PageDataVO static factory methods:

  • PageDataVO.build(PageDataDTO dto, Class<V> clazz) — Convert from DTO
  • PageDataVO.build(currentPage, pageSize, totalRecords, List<V> records) — Build manually
  • PageDataVO.empty() — Empty pagination

Annotation Quick Reference

AnnotationTargetModuleKey Parameters
@CheckSessionTYPE, METHODhoutu-web-securityvalue(bool, default true)
@RequiresRoleMETHODhoutu-web-securityvalue(String[]), logic(Logic.OR/AND, default OR)
@RequiresPermissionMETHODhoutu-web-securityvalue(String[]), logic(Logic.OR/AND, default OR)
@CheckSignTYPE, METHODhoutu-web-securityvalue(bool, default true)
@CheckRepeatRequestTYPE, METHODhoutu-web-security(no parameters)
@LockMETHODhoutu-cacheprefix(String), key(String), leaseTime(long, -1), waitTime(long, -1), unit(TimeUnit.SECONDS)
@AccessLogTYPE, METHODhoutu-access-logvalue(bool), requestHeaders(String[], default USER_AGENT), requestBody(bool, default false), logFilterHandler(Class)
@SecurityWatchTYPE, METHODhoutu-data-securityencrypt(bool), encryptMapKeys(String[]), decrypt(bool), decryptMapKeys(String[]), processorBeanName(String), processorClass(Class)
@SecurityParamPARAMETER, FIELDhoutu-data-security(no parameters)
@AutoFeignTYPE, METHODsc-houtu-feignvalue(bool, default true), responseBody(bool, default true)
@NotXssFIELD, PARAMETERhoutu-webmessage(String, default "内容包含不安全信息")

Predefined Error Codes (ErrorCodeConstant)

CodeConstantDescription
0SUCCESSSuccess
1INTERNAL_ERRORInternal error
2SERVER_BUSYServer busy
3NETWORK_ERRORNetwork error
4OPERATION_FAILOperation failed
5REQUEST_INVALIDInvalid request
6REQUEST_INVALID_IPInvalid IP
7REQUEST_INVALID_DATAInvalid data
8REQUEST_REPEATDuplicate request
9REQUEST_TOO_FREQUENCYRequest too frequent
10USERNAME_NOT_EXISTUsername does not exist
11ACCOUNT_LOCKEDAccount locked
12ACCOUNT_EXCEPTIONAccount exception
13PASSWORD_ERRORPassword error
14USERNAME_OR_PASSWORD_ERRORUsername or password error
15SESSION_EXPIREDSession expired
16SESSION_KICK_OUT_EXPIREDSession kicked out
17INVALID_VERIFICATION_INFOInvalid verification info
18INVALID_SIGNATURE_INFOInvalid signature
19ACCESS_PERMISSIONS_DENIEDAccess denied
30PARAMETER_ERRORParameter error
31PARAMETER_FORMAT_ERRORParameter format error
32NOT_SUPPORTED_PARAMETER_TYPE_CONVERSIONParameter type conversion not supported
40DATA_LOADING_FAILEDData loading failed
41DATA_NOT_EXISTData does not exist
42DATA_ALREADY_EXISTData already exists (in v2.7.1, v3.5.0, v3.5.1 this was 41, same as DATA_NOT_EXIST — a bug fixed in v2.7.2+ and v3.5.2)

Custom business error codes should start from 100, built via ErrorCode.build(code), with i18n support.


Source Code Verification (Fallback)

When reference files do not cover a specific API or you need to confirm parameters, read framework source code via git show:

git show <branch>:<file-path>
ModuleKey Source Files (under src/main/java/)
houtu-core.../core/exception/BusinessException.java, .../core/exception/ErrorCode.java, .../core/constant/ErrorCodeConstant.java, .../core/context/SpringApplicationContext.java
houtu-web.../web/model/ResponseData.java, .../web/model/EmbedResponseData.java, .../web/model/vo/PageDataVO.java, .../web/model/form/PageForm.java, .../web/handler/UnifiedHandlerExceptionResolver.java, .../web/validation/constroins/NotXss.java
houtu-web-security.../websecurity/annotation/*.java, .../websecurity/session/SessionContext.java
houtu-cache.../lock/annotation/Lock.java, .../lock/support/LockSupport.java, .../lock/support/BLock.java, .../limit/RateLimiter.java
houtu-data-security.../data/security/annotation/SecurityWatch.java, .../data/security/handler/SecurityProcessor.java
houtu-access-log.../accesslog/annotation/AccessLog.java, .../accesslog/handler/LogFilterHandler.java
houtu-utils.../util/crypto/*.java, .../util/JsonUtils.java, .../util/HttpClients.java
houtu-actuator.../actuator/metrics/*.java
sc-houtu-loadbalancer.../loadbalancer/support/hint/HintContext.java
sc-houtu-feign.../feign/anotation/AutoFeign.java
sc-houtu-discovery.../discovery/context/ServiceContext.java

Path prefix: io/github/lujiafa/houtu Note: The package name for @AutoFeign is anotation (not annotation); this is the framework's original spelling.


Version Quick Comparison

Featurev3.5.2v3.5.1v3.5.0v2.7.3v2.7.2v2.7.1
JDK17+17+17+1.8+1.8+1.8+
Spring Boot3.5.113.5.113.5.112.7.182.7.182.7.18
Package prefixio.github.lujiafa.houtuSameSameSameSameSame
Namespacejakarta.*jakarta.*jakarta.*javax.*javax.*javax.*
Redis configspring.data.redis.*SameSamespring.redis.*spring.redis.*spring.redis.*
Nacos configspring.config.importSamebootstrap.ymlbootstrap.ymlbootstrap.ymlbootstrap.yml
SCA version2025.0.0.0Same2023.0.1.22021.0.6.22021.0.6.22021.0.6.2
@Lock SpEL

See version details at references/v{version}.md

Capabilities

skillsource-lujiafaskill-houtu-dependenciestopic-agent-skillstopic-claude-codetopic-claude-skillstopic-skill-mdtopic-skillsmp

Install

Quality

0.46/ 1.00

deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 19 github stars · SKILL.md body (21,286 chars)

Provenance

Indexed fromgithub
Enriched2026-04-23 19:05:09Z · deterministic:skill-github:v1 · v1
First seen2026-04-23
Last seen2026-04-23

Agent access