code-audit

GitHub

用于扫描代码库架构问题、文件行数违规及MVI合规性,并生成可操作的增量重构计划。支持自动化审计脚本执行与四阶段重构流程,确保代码规范与低回归风险。

.agents/skills/code-audit/SKILL.md pass-with-high-score/blockads-android

Trigger Scenarios

用户要求审查代码或查找需重构的文件 需要执行代码质量审计以识别架构缺陷

Install

npx skills add pass-with-high-score/blockads-android --skill code-audit -g -y
More Options

Non-standard path

npx skills add https://github.com/pass-with-high-score/blockads-android/tree/main/.agents/skills/code-audit -g -y

Use without installing

npx skills use pass-with-high-score/blockads-android@code-audit

指定 Agent (Claude Code)

npx skills add pass-with-high-score/blockads-android --skill code-audit -a claude-code -g -y

安装 repo 全部 skill

npx skills add pass-with-high-score/blockads-android --all -g -y

预览 repo 内 skill

npx skills add pass-with-high-score/blockads-android --list

SKILL.md

Frontmatter
{
    "name": "code-audit",
    "description": "Scan the codebase for architectural issues, files exceeding 500 lines, missing MVI contracts, duplicate code, and gomobile interop risks, and generate actionable refactoring plans. Use when the user asks to \"audit code\", \"check code issues\", \"find files to refactor\", or \"refactor screen\"."
}

Code Audit & Refactoring Skill

This skill diagnoses code smells, architectural violations, and rule non-compliance across the blockads-android project, then guides safe, incremental refactoring according to project standards (GEMINI.md and .agents/rules/).

Capabilities

  1. Automated Codebase Audit:

    • Detect files exceeding the 500-line limit (both Kotlin and Go).
    • Identify UI screen modules missing dedicated *Contract.kt files (MVI compliance).
    • Identify god-classes and monoliths needing decomposition.
    • Verify gomobile interop constraints in tunnel/.
  2. Targeted Refactoring Workflows:

    • Splitting large composables (>500 lines) into focused sub-composables in dedicated files.
    • Converting legacy screens to standard MVI (Contract + Screen + ViewModel).
    • Breaking down monolithic services (e.g., AdBlockVpnService.kt, AppPreferences.kt) into delegates.

How to Run an Audit

Execute the built-in audit script from the terminal:

python3 .agents/skills/code-audit/scripts/audit_codebase.py

This generates an instant Markdown report covering:

  • File line count violations categorized by severity (🔴 Critical > 750 lines, 🟡 Warning > 500 lines).
  • UI modules lacking dedicated MVI Contracts.
  • Gomobile compatibility issues.
  • Prioritized refactoring roadmap.

4-Phase Refactoring Process

When tasked with refactoring any module or screen identified by the audit:

Phase 1: Diagnosis & Scope Definition

  • Run the audit script or inspect the target file.
  • Identify the exact responsibilities of the file.
  • Define what parts will be extracted (e.g., UI dialogs, card items, state models, helper functions).

Phase 2: Refactoring Plan

Draft a concise plan detailing:

  1. Target File: File to be decomposed.
  2. New Extracted Files:
    • *Contract.kt: Immutable UiState, UiIntent, UiEffect.
    • components/*Item.kt or components/*Dialog.kt: Extracted stateless composables.
    • *Delegate.kt or *Helper.kt: Extracted business logic or DataStore operations.
  3. Target line count for each file (all strictly < 500 lines).

Phase 3: Execution (Incremental & Atomic)

  • Extract independent contracts/models first.
  • Extract reusable UI components into ui/components/ or screen-specific subpackages.
  • Keep the main Screen or Service as an orchestrator with a flat hierarchy.
  • Ensure all dependencies are injected via Koin constructor injection.

Phase 4: Taste Test & Verification

  • Compile the project:
    ./gradlew assembleDebug
    
  • Run unit tests:
    ./gradlew test
    
  • If modifying Go tunnel:
    ./gradlew buildGoTunnel
    
  • Verify zero regression in functionality and confirm all new files are under 500 lines.

Version History

  • d0a14c3 Current 2026-09-27 14:55

    将文档中所有 .agent 引用标准化为 .agents。

  • 4938bb2 2026-09-22 03:58

Same Skill Collection

.agent/skills/blockads-dev/SKILL.md
.agent/skills/cook/SKILL.md
.agent/skills/csv-translator/SKILL.md
.agent/skills/github-issue-manager/SKILL.md
.agent/skills/upgrade-app/SKILL.md
.agents/skills/adblock-fixer/SKILL.md
.agents/skills/blockads-dev/SKILL.md
.agents/skills/cook/SKILL.md
.agents/skills/github-issue-manager/SKILL.md
.agents/skills/upgrade-app/SKILL.md
.agents/skills/browser-adblock-agent/SKILL.md

Metadata

Files
0
Version
d0a14c3
Hash
dc22aff7
Indexed
2026-09-22 03:58

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-28 05:32
浙ICP备14020137号-1