Xpersona
A

Architecture Consistency Guardian

CLAWHUB · Unverified

Enforce system-wide consistency before code changes. Activate for any task involving: refactoring across files, unifying variable/field/parameter names, cons... Skill: Architecture Consistency Guardian Owner: upsightx Summary: Enforce system-wide consistency before code changes. Activate for any task involving: refactoring across files, unifying variable/field/parameter names, cons... Tags: latest:2.0.1 Version history: v2.0.1 | 2026-04-14T10:41:28.785Z | user Add default/lite/strict scan modes, reference-aware drift filtering, and regression tests. v2.0.0 | 2026-04-14T08:29

62
Rank
84
Safety
966
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 966 downloads reported by the source. Last updated 10/12/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17exdt2qpdm7p8x6gbbsx37v584gr15:architecture-consistency-guardian
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-upsightx-architecture-consistency-guardian/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

95,267 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: architecture-consistency-guardian
description: >
  Enforce system-wide consistency before code changes. Activate for any task involving:
  refactoring across files, unifying variable/field/parameter names, consolidating state machines,
  cleaning legacy paths or fallbacks, aligning configuration sources, unifying database schema,
  consolidating service entry points, aligning documentation with code, or preventing local-only
  fixes that ignore global architecture contracts.

  Trigger signals: "统一一下", "全局改", "别只修当前文件", "检查所有引用", "清理 legacy",
  "状态机不统一", "配置路径不一致", "多个模块都要改", "架构收口", "重构", "修复兼容层",
  "把新旧逻辑统一", "unify", "consolidate", "clean up legacy", "align across modules",
  "single source of truth", "remove fallback", "schema drift".

  Also activate when a reported bug may stem from contract drift (e.g., mismatched field names,
  stale fallback paths, dual write targets, or status values not in the canonical set).

  NOT for: pure greenfield feature development with no cross-file impact, cosmetic lint/format
  changes, or single-file typo fixes with zero external references.
---

# Architecture Consistency Guardian

## Purpose

Force a **global-first** posture for every code change that touches shared contracts:
names, states, paths, configs, schemas, entry points, fallbacks, or documentation.

The default agent behavior is to patch the immediate error site. This skill overrides
that instinct: **scan globally, identify the single source of truth, modify as a group,
audit for residue, then verify.**

## Mandatory Workflow (8 phases)

Every task under this skill MUST follow these phases in order.
Skip a phase only if you can explicitly justify why it does not apply.

### Phase 1 — Classify the Task

Determine which consistency category applies:

| Category | Examples |
|----------|----------|
| naming | Variable, field, parameter, event name unification |
| state-machine | Status values, transition rules, write-back entry |
| config-path | DB path, env var, runtime config, deploy assumption |
| entry-point | Consolidating orchestrator / service / manager as sole entry |
| schema | Table name, column name, migration, compatibility layer |
| legacy-cleanup | Removing old fallback, old table writes, old function names |
| doc-alignment | Syncing SKILL.md, README, comments, contract docs with code |
| cross-module | Multi-repo or multi-directory coordinated change |

If multiple categories apply, lead with the one closest to the source of truth.

### Phase 2 — Identify the Single Source of Truth

Answer explicitly before writing any code:

1. What is the **canonical file/module** for this contract?
2. Are there **competing sources**? List them.
3. Which one survives, which ones get retired?

If no architecture contract document exists, produce a **temporary contract summary**
(inline in your plan) covering: canonical state field, canonical write entry, canonical
config source, and legacy items to retire. Read `references/contract_templa

README.md

# Architecture Consistency Guardian 架构一致性守卫

你的 AI 编程助手是不是也这样——修了一个 bug,却在三个文件里留下了旧变量名?改了状态机,但 fallback 还在偷偷把流量导回旧逻辑?

这个 [OpenClaw](https://github.com/openclaw/openclaw) Skill 专治这个病。它把 AI Agent 的默认姿势从“哪里报错补哪里”,切换为 **全局扫描 → 唯一真源 → 成组修改 → 残留审计 → 回归验证** 的完整工作流。它不只是教模型“写代码”,而是强制模型先对齐架构契约,再落地修改。

## 解决什么问题

AI Agent 或人类修代码时,常见的问题不是不会改,而是**只改半截**。例如只修当前文件、不追踪调用方;改了状态值、不检查其他模块是否还在用旧值;统一了配置路径,却把硬编码副本留在文档或脚本中;删除了旧模块,但兼容 fallback 仍在静默回流。

这个 Skill 的目标就是在这些场景里强制执行“先全局、后修改”的姿势,避免局部修复把系统进一步拉散。

## 适用场景

- 跨文件统一变量、字段、参数命名
- 状态机收口,统一状态值、迁移规则和写回入口
- 清理 legacy 路径、fallback 和已退役模块
- 统一配置来源,如数据库路径、环境变量、运行时配置
- 重构后同步文档与代码
- 修 bug 时发现根因可能是架构契约漂移

## 强制 8 阶段工作流

1. **归类**:判断一致性问题类别,如命名、状态机、配置路径。
2. **识别唯一真源**:找到权威文件,并标记竞争真源。
3. **全局扫描**:搜索所有相关引用,而不是只看当前文件。
4. **修改计划**:列出受影响文件和具体改动,再开始实施。
5. **成组执行**:按顺序修改真源、调用方、配置层、兼容层、测试与文档。
6. **残留审计**:确认旧名称、旧状态、旧路径、旧 fallback 是否仍存在。
7. **回归验证**:运行测试、验证零残留、确认配置解析和核心行为。
8. **结构化报告**:输出真源、影响范围、已改内容、残留兼容层和验证结果。

## 内置脚本

| 脚本 | 用途 |
|------|------|
| `scripts/grep_legacy.py` | 扫描旧名称、旧路径、旧状态残留 |
| `scripts/scan_contract_drift.py` | 检测多个竞争真源 |
| `scripts/summarize_impacts.py` | 聚合扫描结果并输出影响面摘要 |

## 使用示例

```bash
# 扫描 legacy 残留
python3 scripts/grep_legacy.py /path/to/project old_status_field legacy_module_name

# 检测契约漂移(多处定义同一个东西)
python3 scripts/scan_contract_drift.py /path/to/project

# 管道:legacy 扫描结果 → 影响面摘要
python3 scripts/grep_legacy.py /path/to/project old_name --json | \
  python3 scripts/summarize_impacts.py --source-of-truth config.py

# 管道:contract drift 结果 → 摘要
python3 scripts/scan_contract_drift.py /path/to/project --json | \
  python3 scripts/summarize_impacts.py --source-of-truth runtime_config.py
```

## JSON 输出协议

`grep_legacy.py` 与 `scan_contract_drift.py` 的 `--json` 现在使用统一外层协议,便于自动化链路、测试和后续扩展:

```json
{
  "tool": "grep_legacy",
  "schema_version": "1.0",
  "scan_root": "/repo",
  "generated_at": "2026-04-14T12:00:00Z",
  "results": [],
  "summary": {},
  "errors": []
}
```

其中 `results` 会根据工具类型携带不同的明细项,而 `summarize_impacts.py` 会根据 `tool` 字段自动识别来源并生成对应摘要。

## 工程化入口

```bash
# 编译检查
make compile

# 运行测试
make test

# 基础冒烟验证
make smoke
```

GitHub Actions 默认会在 Push 和 Pull Request 时执行脚本编译与测试。

## 目录结构

```text
architecture-consistency-guardian/
├── .github/workflows/ci.yml      # 持续集成
├── SKILL.md                      # 核心工作流与硬规则
├── Makefile                      # 本地开发命令入口
├── pyproject.toml                # 项目元数据与 pytest 配置
├── references/
│   ├── workflow.md               # 详细工作流与决策分支
│   ├── output_template.md        # 结构化报告模板
│   ├── risk_patterns.md          # 常见一致性风险模式
│   └── contract_template.md      # 架构契约文档模板
├── templates/
│   ├── consistency_report_template.md
│   └── architecture_contract_template.md
├── scripts/
│   ├── grep_legacy.py
│   ├── scan_contract_drift.py
│   └── summarize_impacts.py
└── tests/
    └── test_cli_workflows.py
```

## 安装

### ClawHub(推荐)

```bash
clawhub install architecture-consistency-guardian
```

### skills.sh

```bash
npx skills add upsightx/architecture-consistency-guardian
```

##

_meta.json

{
  "ownerId": "kn79991jcvbwn65dvrwpbre2g184hp3q",
  "slug": "architecture-consistency-guardian",
  "version": "2.0.1",
  "publishedAt": 1776163288785
}

references/contract_template.md

# Architecture Contract Template

Use this template when a project lacks a formal architecture contract document.
Copy this file, fill in the sections, and place it at the project root as
`ARCHITECTURE_CONTRACT.md`.

---

```markdown
# Architecture Contract

> Auto-generated by architecture-consistency-guardian.
> Last updated: YYYY-MM-DD

## 1. Canonical Sources of Truth

| Domain | Canonical File | Notes |
|--------|---------------|-------|
| Config / paths | `runtime_config.py` | All path constants read from here |
| State machine | `lifecycle_manager.py` | Defines valid states + transitions |
| DB schema | `schema.py` or migrations/ | Column definitions live here |
| Observation writes | `memory_governor.py` | Sole write gateway for observations |
| Proposal lifecycle | `proposal_lifecycle_manager.py` | Sole status authority |
| Orchestration | `orchestrator.py` | Sole entry point for workflow dispatch |

## 2. Canonical State Values

### [Entity: e.g., Proposal]

| State | Meaning | Allowed transitions |
|-------|---------|-------------------|
| draft | Initial creation | → pending_review |
| pending_review | Awaiting approval | → approved, → rejected |
| approved | Ready for execution | → experimenting |
| experimenting | Running experiment | → validated, → failed |
| validated | Experiment succeeded | → released |
| failed | Experiment failed | → draft (retry), → archived |
| released | Deployed to production | → archived |
| archived | End of life | (terminal) |

**Retired states** (must not appear in new code):
- `pending` — replaced by `pending_review`
- `applied` — replaced by `experimenting`

## 3. Canonical Entry Points

| Operation | Entry Module | Bypass Allowed? |
|-----------|-------------|----------------|
| Create proposal | orchestrator.py | No |
| Advance proposal state | lifecycle_manager.py | No |
| Write observation | memory_governor.py | No |
| Read config path | runtime_config.py | No |
| External learning intake | proposal_bridge.py | No |

## 4. Retired Components

| Component | Retired Date | Replacement | Residual Locations |
|-----------|-------------|-------------|-------------------|
| feedback_loop.py | 2026-04-08 | capability_detector.py | None |
| change_applier.py | 2026-04-08 | evolution_executor.py | None |
| evolution_changes table | 2026-04-08 | proposals table | Read-only fallback |

## 5. Compatibility Layers

| Layer | Location | Reason | Removal Condition |
|-------|----------|--------|-------------------|
| evolution_changes read | executor.py:L120 | Migration period | After all data migrated |

If this section is empty, the system has no active compatibility layers.

## 6. Rules

1. **Single write path**: Every data store has exactly one write gateway module.
2. **Config from source**: No hardcoded paths; all paths from runtime_config.
3. **State from authority**: State reads/writes only through the lifecycle manager.
4. **No silent fallback**: ImportError/except blocks must not route to retired modu

references/output_template.md

# Consistency Report Template

Use this template for the Phase 8 structured report.

## Report Structure

```markdown
## Consistency Report

### 1. Classification
- **Category**: [naming | state-machine | config-path | entry-point | schema | legacy-cleanup | doc-alignment | cross-module]
- **Sub-categories** (if applicable): [list]
- **Trigger**: [What prompted this task]

### 2. Source of Truth
- **Canonical file/module**: [path]
- **Competing sources found**: [list or "none"]
- **Resolution**: [which survived, which retired]

### 3. Scope
- **Files modified**: [count]
- **Files scanned**: [count]
- **Repos involved**: [list]

| File | Change Type | Description |
|------|------------|-------------|
| path/to/file.py | renamed field | old_name → new_name |
| path/to/other.py | removed fallback | deleted legacy import path |
| ... | ... | ... |

### 4. Changes Made
[Concise description of what was unified/renamed/removed/updated, grouped logically]

### 5. Residual Compatibility
| Item | Location | Reason for Retention | Removal Condition |
|------|----------|---------------------|-------------------|
| old_function() | module.py:42 | External dep X | After X migrates |
| ... | ... | ... | ... |

If none: "No residual compatibility layers remain."

### 6. Verification
| Check | Result |
|-------|--------|
| grep old names | 0 hits / N hits (explained) |
| test suite | passed / N failures (explained) |
| config resolution | verified in real layout |
| ... | ... |

### 7. Follow-up Risks (optional)
- [Risk 1: description and suggested mitigation]
- [Risk 2: description and suggested mitigation]
```

## Compact Format

For smaller changes, use this condensed version:

```markdown
## Consistency Report
- **Category**: naming
- **Source of truth**: runtime_config.py
- **Scope**: 4 files modified, 12 scanned
- **Changes**: Unified `db_path` / `DB_PATH` / `database_path` → `DB_PATH` from runtime_config
- **Residual**: None
- **Verification**: grep old names = 0 hits; test suite passed (13/13)
- **Risks**: None identified
```

## Anti-patterns in Reports

Do NOT write reports like:
- ❌ "Fixed the issue." (no detail)
- ❌ "Refactored the module." (no scope)
- ❌ "Updated all references." (no proof)
- ❌ "Everything should be consistent now." (no verification)

Every claim must be backed by a concrete action or check result.

Sponsored

Ads related to Architecture Consistency Guardian and adjacent AI workflows.