Skip to main content

Understanding the Scope Rule

The Scope Rule is the fundamental principle that all agents enforce:

The Scope Rule

“Scope determines structure”
  • Code used by 2+ features → MUST go in global/shared directories
  • Code used by 1 feature → MUST stay local in that feature
  • NO EXCEPTIONS - This rule is absolute and non-negotiable
This approach ensures:
  • Perfect traceability - Know exactly where to find code
  • Screaming architecture - Structure immediately communicates functionality
  • Scalable organization - Grows naturally with your application
  • Zero architectural debt - Prevents the “everything in components/” anti-pattern

First Steps

Once you have the agents installed, simply ask Claude Code architectural questions in your project. The appropriate agent will be invoked automatically based on your framework and question context.

Framework-Specific Examples

Angular Example

The scope-rule-architect-angular agent specializes in Angular 20+ projects with standalone components, signals, and modern patterns.

Ask the Agent

I have a Button component that will be used in both the shopping cart
and user profile features. Where should I put it?

Agent Response

The agent will determine that since the Button component is used by 2+ features (shopping cart and user profile), it must go in the shared/components directory:
// src/app/features/shared/components/button.ts
import {
  Component,
  ChangeDetectionStrategy,
  input,
  output,
} from '@angular/core';

@Component({
  selector: 'app-button',
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <button
      [type]="type()"
      [disabled]="disabled()"
      (click)="handleClick()">
      <ng-content></ng-content>
    </button>
  `,
})
export class ButtonComponent {
  readonly type = input<'button' | 'submit'>('button');
  readonly disabled = input(false);
  readonly clicked = output<void>();

  handleClick(): void {
    this.clicked.emit();
  }
}

Project Structure

src/app/features/
  shopping-cart/
    shopping-cart.ts
    components/           # Cart-specific components
  user-profile/
    user-profile.ts
    components/           # Profile-specific components
  shared/
    components/
      button.ts          # ✅ Used by 2+ features
The Angular agent enforces modern Angular 20 patterns including standalone components, input() and output() functions, and ChangeDetectionStrategy.OnPush.

Common Patterns

Local Component (1 Feature)

If a component is only used within a single feature, it stays local:
User: I have a CartSummary component only used in the shopping cart feature.

Agent: Since CartSummary is used by only 1 feature, it MUST stay local
within the shopping-cart feature directory.

Shared Component (2+ Features)

If a component is used across multiple features, it moves to shared:
User: I have a Button component used in cart, profile, and checkout.

Agent: Since Button is used by 3 features, it MUST go in the shared/components
directory.

Refactoring Existing Code

The agents can help restructure existing projects:
User: My components are all in a single components folder. How should I restructure?

Agent: I'll analyze your component usage and create a structure following the
Scope Rule, organizing components by feature with shared components extracted.

Best Practices

Start Local, Move to Shared

When uncertain about future usage, start with local placement. Refactor to shared when you actually need the component in a second feature.

Let Structure Scream

Your directory structure should immediately communicate what your application does. Use business domain names for features, not technical terms.

Enforce Strictly

The Scope Rule has no exceptions. This strictness prevents architectural debt and keeps your codebase maintainable as it scales.

Next Steps

Build docs developers (and LLMs) love