Guarding
Guarding is a guardians for code, architecture, layered, inspired by ArchUnit. Guarding 是一个用于 Java、JavaScript、Rust、Golang 等语言的架构守护工具。借助于易于理解的 DSL,来编写守护规则。Guarding is a guardians for code, architecture, layered.
Install / Use
/learn @modernizing/GuardingREADME
Guarding
Guarding is a guardians for code, architecture, layered. Using git hooks and DSL for design guard rules.
Inspired by ArchUnit
Usage
use CLI
- install
cargo install guarding
- create
guarding.guardingfile
package(".")::file.len should < 200;
package(".")::file.len should > 50;
- run
guarding .
use API
guarding_adapter, FFI adapter, provide Guarding api,guarding_core, core guarding model,guarding_ident, identify different language: Java, JavaScript, Rustguarding_parserparsing Guarding DSL
Development
workflow:
- parsing guarding rules
- parsing source code to models
- capture rule with models
DSL capture logic:
- filter models from
rule_levelwithrule_scope - run expression
- run assert
Queries Samples: https://github.com/nvim-treesitter/nvim-treesitter/tree/master/queries
Guarding - Class or Struct function-name
for packages:
class(implementation "BaseParser")::name should endsWith "Parser";
class("java.util.Map") only accessed(["com.phodal.pepper.refactor.staticclass"]);
class(implementation "BaseParser")::name should not contains "Lexer";
for Java, JavaScript
# 类::名 包含 "Controller";
# 中文分词:("..myapp..") 类名称中包含 "Controller"
class("..myapp..")::function.name should contains("Model");
# or
class("..myapp..")::function.name contains("");
for Rust and Golang
struct("..myapp..")::function.name should contains("Model");
# or
struct("..myapp..")::function.name contains("");
License
This code is distributed under the MIT license. See LICENSE in this directory.
Related Skills
node-connect
352.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
