# Beyond Manual Code Review? Building an Automated Review Pipeline with JiuwenSwarm ## Introduction — When “code quality” becomes part of daily development In team development, code review is a key safeguard for quality. In practice, though: > After every push, reviewers spend a long time on syntax, style, and security, while the conversations that actually matter get buried. Code review tends to hit three pain points: 1. **Too much repetition** — Syntax, formatting, and basic security checks are repeated by hand every time. 2. **Fragmented tooling** — Linters, security scanners, and complexity tools each run in isolation; results are hard to combine. 3. **No clear metrics** — It is unclear how good the code is; there is no shared score or actionable guidance. If code review is to improve quality, it needs three capabilities: 1. **Multi-dimensional static analysis** (lint + security + complexity) 2. **Intelligent scoring and suggestions** (quantified assessment + direction for improvement) 3. **Multi-channel reporting** (e.g. Feishu notifications + local reports) This article walks through: - How to design a layered analysis stack (Ruff + Radon + Bandit) - How to implement a composite scoring engine (quality + security + complexity + style) - How to build flexible report generators (Markdown reports + Feishu cards) - How to support multiple code sources (local scan + Git clone) - End-to-end implementation and testing If you are asking: - How to move code review from “manual checking” to “intelligent analysis” - How to give code quality a quantifiable score - How to build an extensible analysis pipeline the following sections may offer a useful angle. --- ## Project environment > **This document reflects a real project.** Configuration and code match what was actually used, not placeholder examples. ### Runtime environment | Item | Value | | --- | --- | | **Project path** | `D:\Download\jiuwenswarm` | | **OS** | Windows 10 | | **Python** | 3.10+ | | **Model service** | Zhipu AI (GLM-4.7) | ### Analysis tools | Tool | Version | Purpose | Languages | | --- | --- | --- | --- | | **Ruff** | 0.4.0+ | Python linting (replaces Pylint/Flake8) | Python | | **Radon** | 6.0.0+ | Cyclomatic complexity | Python | | **Bandit** | 1.7.0+ | Security scanning | Python | | **ESLint** | 9.0+ | Code quality | JavaScript/TypeScript | | **Checkstyle** | 10.12+ | Style checks | Java | | **golangci-lint** | latest | General Go checks | Go | | **Clippy** | latest | Linting | Rust | ### Key file layout ```plain D:\Download\jiuwenswarm\ ├── .env # Environment variables ├── workspace/ │ └── agent/ │ ├── reports/code-review/ # Review report output │ └── skills/code-review/ # Skill module │ ├── SKILL.md # Skill definition v2.0.1 │ ├── config.py # Configuration │ ├── run_review.py # Entry script │ ├── models/ # Data models │ ├── collectors/ # Code collection │ ├── analyzers/ # Analysis engine │ └── generators/ # Report generation ``` ## 1. Problem background ### 1.1 Limits of traditional code review When people say “code review,” they often mean: > “Isn’t that just PR review — checking correctness and formatting?” For simple cases, manual review is enough. In real projects you quickly run into three issues: 1. **Low efficiency** Every review re-checks basics: unused imports, hard-coded secrets, oversized functions — work tools should automate. 2. **Inconsistent standards** Different reviewers care about different things; there is no shared, quantitative bar. 3. **Easy to miss issues** Vulnerabilities such as SQL injection or command injection usually need tooling; manual review misses them often. Example: fifteen functions, three with complexity over 20 (grade D), two with possible SQL injection — hard to catch everything in one pass. The **code review assistant** runs three complementary analyzers, feeds a scoring engine, and produces a report with issues and suggestions. ### 1.2 Pain points for developers Typical quality workflows force you to **run many tools before each commit**: Flake8, Pylint, Bandit — each with its own output format to merge by hand. Another gap: **you do not know how good the code really is**. Fifty warnings appear — how serious are they? What is the overall quality? The worst misses are **security issues**: e.g. `os.system(user_input)` overlooked in review but exploitable in production. With the assistant, Ruff (lint), Radon (complexity), and Bandit (security) run automatically; the engine computes quality, security, complexity, and style scores and returns an overall grade with suggestions. ### 1.3 Why JiuwenSwarm’s skill system fits JiuwenSwarm is an open Agent framework; its skill model fits code review tooling: | Capability | Description | | --- | --- | | **Modular skills** | Each skill can bundle multiple Python modules for clean layering | | **Tool integration** | `allowed_tools` grants access to system tools and external commands | | **File I/O** | Read/write files for scanning and report generation | | **Multi-channel delivery** | e.g. Feishu for review summaries | The main idea is **composability**: collection, static analysis, and reporting are separated with clear boundaries. ## 2. Technical approach ### 2.1 Layered architecture The code review skill lives in JiuwenSwarm’s application layer and uses a classic three-tier layout: ``` ┌─────────────────────────────────────────────────────────┐ │ Application Layer │ │ (code-review skill) │ ├─────────────────────────────────────────────────────────┤ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ Collectors │→ │ Analyzers │→ │ Generators │ │ │ │ Collection │ │ Analysis │ │ Reports │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ │ │ │ │ LocalCollector RuffAnalyzer ReportGenerator │ │ AtomGitClient RadonAnalyzer FeishuPublisher │ │ BanditAnalyzer │ │ ScoreCalculator │ └─────────────────────────────────────────────────────────┘ ``` ### 2.2 Data flow End-to-end review flow: ``` User / conversation triggers: review code │ ▼ ┌──────────────────┐ │ COLLECTORS │ Code collection │ LocalCollector │ Local directory scan │ AtomGitClient │ Git clone └────────┬─────────┘ │ ▼ ┌──────────────────┐ │ ANALYZERS │ Multi-dimensional analysis │ RuffAnalyzer │ Lint → lint_issues │ RadonAnalyzer │ Complexity → complexity_issues │ BanditAnalyzer │ Security → security_issues │ ScoreCalculator │ Scoring → ReviewScore └────────┬─────────┘ │ ▼ ┌──────────────────┐ │ GENERATORS │ Reporting │ ReportGenerator │ Markdown report │ FeishuPublisher │ Feishu card └────────┬─────────┘ │ ▼ ┌──────────────────┐ │ OUTPUT │ │ Local .md file │ │ Feishu card │ └──────────────────┘ ``` ### 2.3 Core components | Component | Type | Role | Module | | --- | --- | --- | --- | | **LocalCollector** | Collector | Local file collection | `collectors/local_collector.py` | | **AtomGitClient** | Collector | Git clone and file access | `collectors/atomgit_client.py` | | **RuffAnalyzer** | Analyzer | Lint | `analyzers/ruff_analyzer.py` | | **RadonAnalyzer** | Analyzer | Complexity | `analyzers/radon_analyzer.py` | | **BanditAnalyzer** | Analyzer | Security | `analyzers/bandit_analyzer.py` | | **ScoreCalculator** | Analyzer | Composite score | `analyzers/score_calculator.py` | | **ReportGenerator** | Generator | Markdown reports | `generators/report_generator.py` | | **FeishuPublisher** | Generator | Feishu delivery | `generators/feishu_publisher.py` | ### 2.4 Scoring model Weighted multi-dimensional scoring: | Dimension | Weight | Basis | | --- | --- | --- | | **Code quality** | 35% | Lint issue count and severity | | **Security** | 30% | Security findings and severity | | **Complexity** | 20% | Cyclomatic complexity and high-complexity functions | | **Style** | 15% | Style issues | Overall score maps to grades: | Grade | Range | Meaning | | --- | --- | --- | | A | 90–100 | Excellent | | B | 80–89 | Good | | C | 70–79 | Acceptable | | D | 60–69 | Needs improvement | | F | Below 60 | Fail | ## Chapter 3 — Engineering the Skills layout ### 3.1 Directory structure ```plain workspace/agent/skills/code-review/ ├── SKILL.md # Skill definition (required) ├── config.py # Configuration ├── run_review.py # Entry script │ ├── models/ # Data models │ ├── __init__.py │ ├── code_issue.py │ ├── code_metrics.py │ ├── review_result.py │ └── review_score.py │ ├── collectors/ # Collection layer │ ├── __init__.py │ ├── local_collector.py │ └── atomgit_client.py │ ├── analyzers/ # Analysis layer │ ├── __init__.py │ ├── ruff_analyzer.py │ ├── radon_analyzer.py │ ├── bandit_analyzer.py │ ├── ast_analyzer.py │ └── score_calculator.py │ └── generators/ # Report layer ├── __init__.py ├── report_generator.py └── feishu_publisher.py ``` ### 3.2 SKILL.md definition (v2.0.1) ```markdown --- name: code-review version: 2.0.1 description: Multi-language code review assistant for Python/JavaScript/Java/Go/Rust; quality, security, and complexity tags: [code, review, python, javascript, typescript, java, go, rust, quality, security] allowed_tools: [mcp_exec_command, read_file, write_file] --- # Multi-language code review assistant Review code in arbitrary Git repositories across multiple languages; detect security, quality, and complexity issues. ## Supported languages | Language | Lint | Security | Complexity | |----------|------|----------|------------| | **Python** | Ruff | Bandit | Radon | | **JavaScript/TypeScript** | ESLint | eslint-plugin-security | — | | **Java** | Checkstyle | — | — | | **Go** | golangci-lint | gosec | gocyclo | | **Rust** | Clippy | cargo-audit | — | ## Usage ### Review a remote Git repository ```bash cd D:/Download/jiuwenswarm && python workspace/agent/skills/code-review/run_review.py clone --url ``` ### Review local code ```bash cd D:/Download/jiuwenswarm && python workspace/agent/skills/code-review/run_review.py local --path ``` ## Important limits **Do not read and return the full report file.** Large repositories can produce tens of thousands of lines, which can: - Exceed WebSocket message size (1MB limit) - Fail to send, so the user sees nothing **Correct approach:** 1. Extract a summary from command output 2. Return a short Feishu-friendly summary 3. Tell the user the detailed report was saved ## Feishu-friendly summary format ``` 📊 Code review report ━━━━━━━━━━━━━━━━━━━━━━ 📦 Repo: 📁 Files scanned: ⏰ Review time: