agentsclimarketplace

Coding rules

Skill navraj007in/architecture-cowork-plugin/skills/coding-rules

Generate AI-consumable coding rules (CLAUDE.md, .cursorrules, copilot-instructions) and enforcement tooling from SDLFrom its SKILL.md

Install
npx -y skills add navraj007in/architecture-cowork-plugin --skill coding-rules

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

13.1 KB, as published. Nobody here has run it

Coding Rules Generator

Generate architecture-aware coding rules that AI coding tools (Claude Code, Cursor, GitHub Copilot) enforce automatically across every session. Optionally generates hard enforcement tooling (ESLint, dependency-cruiser, pre-commit hooks, architecture tests).

Input: SDL document Output: CLAUDE.md, .cursorrules, .github/copilot-instructions.md, per-project CLAUDE.md, optional enforcement configs


What It Generates

Advisory Rules (CLAUDE.md / .cursorrules / copilot-instructions.md)

A single markdown file (output to 3 locations for tool coverage) containing architecture-derived coding rules organized by category:

CategorySource SDL SectionExample Rules
Architecturearchitecture.styleModule boundary rules, service isolation, communication patterns
File Structurearchitecture.projectsFramework conventions, ORM patterns, folder organization
Data AccessdataRepository pattern, database query rules, search engine usage
API Patternsarchitecture.projects.backendREST/GraphQL/gRPC conventions, versioning, service base paths
AuthenticationauthProvider-specific rules (Clerk/Auth0/Cognito), token handling, RBAC
Error HandlingerrorHandlingError format, global handler, circuit breaker, retry patterns
IntegrationsintegrationsService client isolation, webhook handling, payment/email patterns
TestingtestingFramework-specific rules, coverage targets, test structure
ObservabilityobservabilityLogging rules, tracing, metrics collection
SecuritynonFunctional.securityPII handling, encryption, audit logging, OWASP compliance
Cachingdata.cacheCache invalidation, TTL, cache-aside pattern
Queuesdata.queuesMessage handling, idempotency, dead letter queues
Code Quality(always generated)SOLID principles, naming, DRY, single responsibility
Design Patterns(always generated)Framework-appropriate patterns (repository, factory, strategy)
File Size & Structure(always generated)Max file length, function complexity, extraction rules
API Design Quality(always generated)Pagination, filtering, consistent responses, HATEOAS
Database Queries(always generated)N+1 prevention, indexing, query optimization
Testing Quality(always generated)AAA pattern, test naming, mocking boundaries
Performance(always generated)Lazy loading, pagination, connection pooling
Import Organization(always generated)Import ordering, barrel exports, circular dependency prevention
Tech Debt Avoidance(always generated)TODO tracking, deprecation patterns, refactoring triggers
Resilience(always generated)Retry policies, timeouts, fallbacks, circuit breakers
Input Validation(always generated)Schema validation, sanitization, boundary validation
Concurrency(always generated)Race conditions, locking, atomic operations
Configuration(always generated)Env var patterns, secrets management, feature flags
Migration Safety(always generated)Backward compatibility, zero-downtime deploys, rollback
Documentation(always generated)When to document, inline comments, API docs
Git Workflow(always generated)Branch naming, commit messages, PR conventions

Conditional Categories (added when applicable)

CategoryConditionRules
AccessibilityFrontend projects existWCAG compliance, ARIA, keyboard navigation, color contrast
State ManagementFrontend projects existFramework-specific state rules (React Context, Redux, Zustand)
MobileMobile projects existPlatform guidelines, navigation, permissions, offline
InternationalizationMultiple regions definedi18n patterns, locale handling, RTL support

Per-Project Rules

For monorepo setups, generates {project-name}/CLAUDE.md with project-specific rules:

  • Backend: framework conventions, API style, ORM patterns, port assignment
  • Frontend: rendering mode, styling approach, component library, state management

Enforcement Tooling (Optional)

When coding-rules-enforcement is in artifacts.generate, produces hard gates:

FilePurposeLanguage
.eslintrc.sdl.jsCustom ESLint rules from architectureTypeScript/JS
pyproject.sdl.tomlRuff/flake8 config from architecturePython
.golangci.sdl.ymlgolangci-lint config from architectureGo
.dependency-cruiser.sdl.cjsModule boundary enforcementTypeScript/JS
.lintstagedrc.sdl.jsonPre-commit hook configAll
tests/architecture.test.tsArchitecture conformance testsTypeScript

How Rules Are Generated

Rules are deterministic — same SDL input always produces identical output. The generator:

  1. Reads architecture style, projects, data layer, auth, integrations from SDL
  2. Applies framework-specific rule templates (e.g., Express error handling vs FastAPI exception handlers)
  3. Adds conditional categories based on project composition
  4. Generates per-project overlays for monorepo setups
  5. Renders all rules into a single markdown document

Framework-Aware Rules

The generator tailors rules to the specific tech stack:

FrameworkTailored Rules
Node.js/ExpressMiddleware patterns, async/await error handling, route organization
Python/FastAPIPydantic models, dependency injection, async endpoints
GoInterface-based design, error wrapping, goroutine safety
.NET 8Controller patterns, DI container, middleware pipeline
Java/SpringBean lifecycle, AOP patterns, Spring Security
Next.jsApp Router conventions, Server Components, RSC boundaries
ReactHook rules, component composition, render optimization

When to Use

  • After /architect:scaffold — generate rules that match the scaffolded project structure
  • After SDL changes — regenerate to keep rules in sync with architecture evolution
  • When onboarding AI tools — drop CLAUDE.md into any project for instant architecture awareness
  • When adding enforcement — use coding-rules-enforcement artifact for CI/CD gates

Integration

The coding rules generator is available as an SDL artifact type:

artifacts:
  generate:
    - coding-rules              # Advisory rules (CLAUDE.md, .cursorrules, copilot-instructions)
    - coding-rules-enforcement  # Hard gates (ESLint, dependency-cruiser, pre-commit, arch tests)

Both are generated via the generate_from_sdl agent tool or the /api/sdl/generate endpoint.


Hard Enforcement Tooling

When coding-rules-enforcement is in artifacts.generate, the advisory rules above are backed by hard gates — linters, module boundary checks, architecture tests, pre-commit hooks, and a CI workflow. All configs are derived deterministically from the SDL document.

API: POST /api/sdl/generate with artifactType: "coding-rules-enforcement" (no dedicated route)

Language Detection

The generator inspects architecture.projects.backend[] and frontend[] frameworks to determine which configs to produce:

FrameworkLanguageConfigs Generated
nodejsTypeScriptESLint, dependency-cruiser, arch tests
nextjs, react, vue, angular, svelteTypeScriptESLint (with React hooks/a11y if applicable)
python-fastapiPythonRuff + Mypy config
goGogolangci-lint config
java-springJavaArchUnit tests
dotnet-8C#NetArchTest tests

Files Produced

FileLanguagePurpose
.eslintrc.sdl.jsTypeScript/JSCustom ESLint rules from SDL architecture
pyproject.sdl.tomlPythonRuff lint + Mypy strict + pytest coverage config
.golangci.sdl.ymlGo16+ linters with complexity limits
.dependency-cruiser.sdl.cjsTypeScript/JSModule boundary enforcement (modular-monolith/microservices)
.lintstagedrc.sdl.jsonAllPre-commit hook command mapping
.husky/pre-commitAllGit pre-commit hook script
__tests__/architecture.sdl.test.tsTypeScriptArchitecture conformance tests
src/test/java/architecture/ArchitectureTest.javaJavaArchUnit architecture tests
tests/Architecture.Tests/ArchitectureTests.cs.NETNetArchTest architecture tests
.github/workflows/enforce-architecture.ymlAllCI gate workflow

ESLint Rules (TypeScript/JS)

20+ rules enforced:

  • @typescript-eslint/no-explicit-any: error — no any type
  • max-params: 3 — max function parameters
  • no-console: error (allow warn) — no console.log in production
  • no-var, prefer-const — modern variable declarations
  • no-magic-numbers: warn — avoid unlabeled constants
  • max-depth: 3 — max nesting depth
  • max-lines: 500 — max file size
  • max-lines-per-function: 50 — max function length
  • @typescript-eslint/consistent-type-imports — type-only imports
  • import/no-cycle — no circular imports
  • import/order — enforced import ordering
  • @typescript-eslint/naming-convention — camelCase functions, PascalCase types, UPPER_CASE enums
  • @typescript-eslint/no-floating-promises — no unhandled promises
  • no-await-in-loop: warn — avoid sequential async in loops
  • @typescript-eslint/no-unused-vars — no dead code

React-specific (when frontend uses React/Next.js):

  • react-hooks/rules-of-hooks — hook call rules
  • react-hooks/exhaustive-deps — dependency arrays
  • jsx-a11y/* — accessibility rules (alt-text, valid anchors, key events, labels)

Dependency Cruiser Rules (Module Boundaries)

Generated when architecture.style is modular-monolith or microservices:

RuleSeverityWhat It Prevents
no-circularerrorCircular dependencies
no-cross-module-internalserrorImporting another module's internal files (only .interface.ts and .types.ts allowed)
no-db-in-routeserrorRoutes importing database directly
no-repository-in-routeserrorRoutes bypassing services to access repositories
shared-no-module-importserrorShared utilities depending on business modules
orm-only-in-repositories-{name}errorORM package imported outside repository files

Architecture Tests

TypeScript (__tests__/architecture.sdl.test.ts):

  • Module Boundaries: no module imports another module's repository or internal files
  • Data Access Patterns: service files don't use database client directly; route files don't import repositories
  • Security: no hardcoded secrets (Stripe keys, Anthropic keys, base64 keys)
  • Dependency Graph: runs dependency-cruiser validation (modular-monolith/microservices)
  • Coverage: validates coverage target from SDL testing.coverage.target

Java (ArchitectureTest.java with ArchUnit):

  • Controllers don't access repositories
  • Services don't depend on controllers
  • Repositories don't depend on services
  • No cyclic package dependencies
  • Per-module internal access restrictions

.NET (ArchitectureTests.cs with NetArchTest):

  • Controllers don't reference repositories
  • Services don't depend on controllers
  • Repositories don't depend on services

CI Workflow (.github/workflows/enforce-architecture.yml)

Runs on PR to main/develop and push to main. Jobs by language:

JobSteps
lint-typescriptnpm ci → ESLint → dependency-cruiser → architecture tests
lint-pythonpip install → ruff check → ruff format → mypy → pytest with coverage
lint-gogolangci-lint → go test with coverage threshold
lint-javamvnw verify (includes ArchUnit)
lint-dotnetdotnet restore → dotnet test Architecture.Tests
commit-lintcommitlint (conventional commits)

SDL Sections Used (Enforcement)

SDL SectionWhat It Controls
architecture.projects.backend[].frameworkWhich language configs to generate
architecture.projects.frontend[].frameworkReact hooks/a11y rules, TypeScript linting
architecture.styleEnables dependency-cruiser module boundary rules
architecture.services[]Module names for cross-module import restrictions
architecture.projects.backend[].ormORM-specific import restrictions
testing.coverage.targetCoverage enforcement threshold in CI

Advisory vs. Enforcement

AspectAdvisory rules (above)Enforcement tooling (this section)
OutputCLAUDE.md, .cursorrules, copilot-instructions.mdESLint, Ruff, golangci-lint, tests, CI
EnforcementAdvisory (AI tool reads them)Hard gates (CI blocks violations)
Scope27+ categories of architecture rulesLinting, boundaries, secrets, coverage
WhenAlways usefulWhen team needs CI-level enforcement

Use advisory rules alone for AI-guided development; add coding-rules-enforcement in artifacts.generate for automated CI gates.

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.