solid-detection
Multi-language SOLID detection rules. Project type detection, interface locations, file size limits per language.
When & Why to Use This Skill
This Claude skill automates the enforcement of SOLID principles and architectural standards across multiple programming languages including TypeScript, PHP, Swift, Go, Rust, and Python. It helps developers maintain clean, modular codebases by automatically detecting project types and validating structural constraints such as file size limits and mandatory interface locations.
Use Cases
- Automated Architectural Guardrails: Automatically verify that interfaces, protocols, or traits are placed in the correct architectural layers (e.g., app/Contracts/ for Laravel or src/interfaces/ for Python) to prevent structural decay.
- Complexity Management: Monitor and enforce file line limits across different frameworks to ensure components and modules remain small, readable, and maintainable, triggering warnings when files exceed 100-150 lines.
- Polyglot Project Governance: Standardize code quality checks across diverse technology stacks by using a single tool that adapts its validation logic based on the detected project configuration (e.g., package.json, go.mod, or Cargo.toml).
| name | solid-detection |
|---|---|
| description | Multi-language SOLID detection rules. Project type detection, interface locations, file size limits per language. |
SOLID Detection Skill
Project Detection
Detect project type from configuration files:
# Next.js
[ -f "package.json" ] && grep -q '"next"' package.json
# Laravel
[ -f "composer.json" ] && grep -q '"laravel' composer.json
# Swift
[ -f "Package.swift" ] || ls *.xcodeproj
# Go
[ -f "go.mod" ]
# Rust
[ -f "Cargo.toml" ]
# Python
[ -f "pyproject.toml" ] || [ -f "requirements.txt" ]
Language Rules
Next.js / TypeScript
| Rule | Value |
|---|---|
| File limit | 150 lines |
| Interface location | modules/cores/interfaces/ |
| Forbidden | Interfaces in components/, app/ |
Pattern detection:
^(export )?(interface|type) \w+
Laravel / PHP
| Rule | Value |
|---|---|
| File limit | 100 lines |
| Interface location | app/Contracts/ |
| Forbidden | Interfaces outside Contracts |
Pattern detection:
^interface \w+
Swift
| Rule | Value |
|---|---|
| File limit | 150 lines |
| Interface location | Protocols/ |
| Forbidden | Protocols outside Protocols/ |
Pattern detection:
^protocol \w+
Go
| Rule | Value |
|---|---|
| File limit | 100 lines |
| Interface location | internal/interfaces/ |
| Forbidden | Interfaces outside interfaces/ |
Pattern detection:
^type \w+ interface \{
Python
| Rule | Value |
|---|---|
| File limit | 100 lines |
| Interface location | src/interfaces/ |
| Forbidden | ABC outside interfaces/ |
Pattern detection:
class \w+\(.*ABC.*\)
Rust
| Rule | Value |
|---|---|
| File limit | 100 lines |
| Interface location | src/traits/ |
| Forbidden | Traits outside traits/ |
Pattern detection:
^pub trait \w+
Line Counting
Exclude from count:
- Blank lines
- Comments (
//,/* */,#,""") - Import statements (optional)
# TypeScript/Go/Rust/Swift
grep -v '^\s*$\|^\s*//\|^\s*/\*\|^\s*\*' file
# PHP
grep -v '^\s*$\|^\s*//\|^\s*#\|^\s*/\*\|^\s*\*' file
# Python
grep -v '^\s*$\|^\s*#\|^\s*"""' file
Validation Actions
| Severity | Action |
|---|---|
| Interface in wrong location | BLOCK (exit 2) |
| File over limit | WARNING (exit 0) |
| Missing documentation | WARNING |
Environment Variables
Set by detect-project.sh:
SOLID_PROJECT_TYPE=nextjs|laravel|swift|go|rust|python|unknown
SOLID_FILE_LIMIT=100|150
SOLID_INTERFACE_DIR=path/to/interfaces