home / skills / fusengine / agents / solid-detection

solid-detection skill

/plugins/solid/skills/solid-detection

This skill detects project type and interface locations across languages, enforcing SOLID rules and file-size limits to improve architecture.

npx playbooks add skill fusengine/agents --skill solid-detection

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.6 KB
---
name: solid-detection
description: Multi-language SOLID detection rules. Project type detection, interface locations, file size limits per language.
argument-hint: "[file-or-directory] [--language]"
user-invocable: false
---

# SOLID Detection Skill

## Project Detection

Detect project type from configuration files:

```bash
# 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**:
```regex
^(export )?(interface|type) \w+
```

### Laravel / PHP

| Rule | Value |
|------|-------|
| File limit | 100 lines |
| Interface location | `app/Contracts/` |
| Forbidden | Interfaces outside Contracts |

**Pattern detection**:
```regex
^interface \w+
```

### Swift

| Rule | Value |
|------|-------|
| File limit | 150 lines |
| Interface location | `Protocols/` |
| Forbidden | Protocols outside Protocols/ |

**Pattern detection**:
```regex
^protocol \w+
```

### Go

| Rule | Value |
|------|-------|
| File limit | 100 lines |
| Interface location | `internal/interfaces/` |
| Forbidden | Interfaces outside interfaces/ |

**Pattern detection**:
```regex
^type \w+ interface \{
```

### Python

| Rule | Value |
|------|-------|
| File limit | 100 lines |
| Interface location | `src/interfaces/` |
| Forbidden | ABC outside interfaces/ |

**Pattern detection**:
```regex
class \w+\(.*ABC.*\)
```

### Rust

| Rule | Value |
|------|-------|
| File limit | 100 lines |
| Interface location | `src/traits/` |
| Forbidden | Traits outside traits/ |

**Pattern detection**:
```regex
^pub trait \w+
```

## Line Counting

Exclude from count:
- Blank lines
- Comments (`//`, `/* */`, `#`, `"""`)
- Import statements (optional)

```bash
# 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`:

```bash
SOLID_PROJECT_TYPE=nextjs|laravel|swift|go|rust|python|unknown
SOLID_FILE_LIMIT=100|150
SOLID_INTERFACE_DIR=path/to/interfaces
```

Overview

This skill detects project type and enforces SOLID-related rules across multiple languages. It identifies where interfaces or protocols should live, enforces per-language file size limits, and flags violations with configurable severity. The goal is fast, automated validation during analysis or CI checks.

How this skill works

The skill scans repository configuration files to determine project type (Next.js, Laravel, Swift, Go, Rust, Python, or unknown). For the detected language it applies pattern-based checks to find interface/protocol/trait/ABC declarations, verifies their directory locations, and counts logical lines excluding blanks, comments, and imports. Validation results map to actions: blocking for wrong locations and warnings for size or missing docs.

When to use it

  • Run during pre-commit, CI pipelines, or automated code reviews to enforce interface placement and size limits
  • Integrate into static analysis flows to prevent architectural drift across services
  • Validate third-party contributions to ensure interfaces follow project conventions
  • Audit repository structure before refactoring or modularization

Best practices

  • Run detection early in CI to fail fast on blocking violations
  • Keep interface files concise and within configured line limits to improve maintainability
  • Place interfaces in the declared language-specific interface directory to avoid BLOCK errors
  • Treat warnings (file too large, missing docs) as actionable but non-blocking items
  • Customize file-limit and interface-directory environment variables for monorepos or atypical layouts

Example use cases

  • Detect Next.js projects and ensure TypeScript interfaces live under modules/cores/interfaces/ and are <=150 logical lines
  • Scan a Laravel repo to confirm PHP interfaces exist only under app/Contracts/ and warn on oversized files
  • Validate Swift codebases so protocols are defined in Protocols/ and flag protocols located elsewhere as blocking
  • Enforce Go interface placement under internal/interfaces/ and detect interface type declarations with regex
  • Check Python projects for ABC-based interfaces inside src/interfaces/ and warn on missing documentation

FAQ

How does the skill determine project type?

It looks for language-specific config files (package.json, composer.json, Package.swift, go.mod, Cargo.toml, pyproject.toml, requirements.txt) and simple content checks to infer the project type.

What actions are taken on violations?

Interfaces placed outside the configured directory cause a BLOCK (exit code 2). Files over the line limit and missing documentation produce WARNINGS but do not block CI (exit code 0).