codeprobe-architecture
Original:🇺🇸 English
Not Translated
Analyzes code architecture and structure — layer violations, circular dependencies, god objects, anemic domain models, missing boundaries, directory structure issues, and configuration problems. Generates severity-scored findings with fix prompts. Trigger phrases: "architecture review", "structure check", "layer analysis", "god class".
3installs
Sourcenishilbhave/codeprobe
Added on
NPX Install
npx skill4agent add nishilbhave/codeprobe codeprobe-architectureSKILL.md Content
Standalone Mode
If invoked directly (not via the orchestrator), you must first:
- Read for the output contract, execution modes, and constraints.
../codeprobe/shared-preamble.md - Load applicable reference files from based on the project's tech stack.
../codeprobe/references/ - Default to mode unless the user specifies otherwise.
full
Architecture & Structure Analyzer
Domain Scope
This sub-skill detects architectural and structural issues across these categories:
- Layer Violations — Business logic in controllers, presentation logic in models, database access in views
- Circular Dependencies — Direct or transitive circular imports between modules
- God Objects — Oversized files and classes that do too much
- Anemic Domain Model — Entity classes with no behavior, all logic in service classes
- Missing Boundaries — No clear module/domain separation, cross-feature coupling
- Directory Structure — Framework convention violations, flat directory anti-patterns
- Config/Environment — Hardcoded environment values, missing config abstraction
What It Does NOT Flag
- Small projects/scripts with fewer than 5 files — flat structure is appropriate for small codebases and adding layers would be over-engineering.
- Microservices that intentionally have thin layers — a microservice with a single controller, single service, and single repository is fine by design.
- Framework-standard monolith patterns that are idiomatic — e.g., Laravel's default structure for small-to-medium apps, Rails convention-over-configuration patterns, Next.js app directory conventions.
- Prototypes and proof-of-concept code clearly marked as such.
- Generated code directories (e.g., ,
dist/,build/,.next/).__pycache__/
Detection Instructions
Layer Violations
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| Controllers containing business logic | Scan files in controller directories ( | Major |
| Models/entities containing presentation logic | Scan model/entity files. Flag models that contain: HTML generation, string formatting for display (e.g., | Major |
| Views/components calling database directly | Scan view files ( | Critical |
Circular Dependencies
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| Module A imports B, B imports A (direct or transitive) | Prefer the pre-loaded dependency graph (see "Dependency Graph" subsection below). When present, the graph includes a | Major |
Dependency Graph (pre-loaded)
When invoked via or , the orchestrator pre-computes the import graph by running and provides the JSON in-context between and markers. The JSON schema:
/codeprobe audit/codeprobe architecturescripts/dependency_mapper.py=== DEPENDENCY_GRAPH ====== END DEPENDENCY_GRAPH ===- :
graph— the full dependency graph.{file_path: [files it imports]} - : list of cycle objects, each with the full file-path chain (e.g.,
circular_dependencies).["a.py", "b.py", "c.py", "a.py"] - :
summary— aggregate stats.{total_files, total_cycles, most_imported, most_dependencies}
When the graph is present, treat it as ground truth: every cycle in becomes an finding. Do NOT attempt your own cycle detection — the script runs deterministic DFS and is more reliable than LLM import-tracing.
circular_dependenciesARCHWhen the graph is absent (script failed, Python 3 missing, or degraded mode), fall back to LLM-based import tracing as described in the Circular Dependencies row above.
God Objects
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| File exceeds 500 LOC | Count total lines in each source file (excluding blank lines and comments). Flag files exceeding 500 LOC. For files exceeding 1000 LOC, escalate to critical. | Major |
| Class with 20+ methods | Count public, protected, and private methods in each class. Flag classes with 20+ methods. List the method groups to suggest how the class could be split. | Major |
| Single file handling request-to-response lifecycle | Look for files that handle the full request lifecycle: receiving/parsing the request, validating input, executing business logic, performing persistence, formatting the response, and logging — all in one file or class. Flag when 4+ of these concerns are in a single file. | Major |
Anemic Domain Model
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| Entity/model classes with only getters/setters, zero behavior | Scan model/entity classes. If a class has only property declarations, getters, setters, and constructor assignment — with no business logic methods (no validation, no calculations, no state transitions, no domain rules) — it is an anemic entity. | Minor |
| All logic in "Service" classes operating on dumb data bags | Check if the codebase has a pattern where entity classes are pure data containers and all behavior (validation, calculation, state transitions) lives in separate | Minor |
Missing Boundaries
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| No clear module/domain separation in medium+ projects | For projects with 20+ source files, check whether the code is organized into modules, domains, or bounded contexts. If all source files live in a single flat directory or are only separated by technical layer (controllers/, models/, services/) with no domain grouping, flag it. | Major |
| Shared database tables accessed directly across unrelated features | Search for the same database table name, model, or entity being imported/queried from multiple unrelated modules or feature directories. If | Major |
| Cross-feature direct imports instead of events/interfaces | Check whether feature modules import directly from other feature modules' internal files. For example, | Minor |
Directory Structure
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| Framework conventions violated | Check whether the project follows its framework's expected directory structure. Examples: business logic classes in a | Minor |
| No separation between layers for 20+ files | For projects with 20+ source files, check whether there is any directory-based separation between layers (controllers, services, models, views) or domains. If everything lives in one flat directory, flag it. | Major |
Config/Environment
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| Hardcoded environment-specific values in source code | Search for hardcoded URLs ( | Major |
| Missing environment abstraction | Check whether the project has an environment abstraction layer ( | Minor |
Using file_stats.py
file_stats.pyWhen available, run the file_stats.py script via Bash to get LOC, class count, and method count per file. The script is located in the skill's directory (resolve relative to the skill installation, not the user's project):
reviewscripts/bash
python3 scripts/file_stats.py <target_path>Note: The orchestrator typically runs this script and passes results. If invoked standalone, locate the script in the sibling directory.
codeprobe/scripts/Use this data to:
- Identify god objects (files > 500 LOC, classes with 20+ methods)
- Find the largest files in the project
- Get accurate LOC counts for the summary
If Python 3 or the script is unavailable, estimate from reading files directly using Read. Do not fail the analysis — proceed with manual counting.
file_stats.pyID Prefix & Fix Prompt Examples
All findings use the prefix, numbered sequentially: , , etc.
ARCH-ARCH-001ARCH-002Fix Prompt Examples
- "Move the pricing calculation logic from (lines 40-75) into a new
OrderController@storeclass underPricingService. The controller should injectapp/Services/and callPricingService. The controller should only handle request parsing, service delegation, and response formatting."$this->pricingService->calculate($order) - "Break (850 LOC) into focused services: extract authentication methods (lines 50-200) into
UserManager, profile management (lines 201-450) intoUserAuthService, and notification methods (lines 451-700) intoUserProfileService.UserNotificationServicebecomes a thin facade that delegates to these three services."UserManager - "Resolve the circular dependency between and
billing/InvoiceService: extract the shared interfaceshipping/ShippingCalculatorinto aShippingCostProviderdirectory. Haveshared/contracts/implementShippingCalculator, and haveShippingCostProviderdepend on the interface instead of the concrete class."InvoiceService - "Replace the hardcoded URL at line 23 of
http://localhost:3000/apiwith an environment variable: usesrc/services/ApiClient.tsloaded through the config module. Addprocess.env.API_BASE_URLtoAPI_BASE_URL=http://localhost:3000/api.".env.example - "Create a domain-based directory structure: move ,
UserController,UserService, andUserRepositoryinto aUserPolicydirectory. Repeat forapp/Domains/User/,Order, andPaymentdomains. Each domain directory should contain its own controllers, services, models, and policies."Notification