CLAUDE MAX

Documentation for Developers

CLAUDE-MAX - Full Documentation

DEPRECATED (Session 135): All essential rules have been consolidated into CLAUDE.md. This file is archived for historical reference. DO NOT read this file for current rules. Use CLAUDE.md + MCP get_conventions() instead.


This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. START HERE - Read this files below in the order they are listed, before starting any task (If you already read any of these files before during this session, skip this step and continue with the analysis of the data in this file):

  1. AGENTS.md
  2. AGENTS-AI-Instructions
  3. CLAUDE.md
  4. Claude-Docs (all docs inside)
  5. AI Agent Task System - CRITICAL: Self-learning AI system
  6. Then continue with the analysis of the data in this file:

🤖 AI Agent Task System (Self-Learning)

IMPORTANT: GoGrab Space has a sophisticated AI Agent Task System that tracks your work for continuous improvement. When working on significant tasks:

Decision Logging Protocol

For every non-trivial decision, mentally note:

When to Log Decisions

Log Don't Log
Library/framework choice Fixing typos
Architecture decisions Simple renames
Implementation approach Obvious patterns
Error recovery strategy Standard imports
State management choice Basic CRUD

Backend API (for programmatic logging)

// Create Task
POST /api/ai-agents/tasks
{ type: 'vibe-coding', goal: 'User request summary' }

// Log Decision
POST /api/ai-agents/tasks/:taskId/sessions/:sessionId/decisions
{
  type: 'implementation-choice',
  question: 'Which approach for X?',
  options: ['A', 'B', 'C'],
  chosen: 'B',
  reasoning: 'Why B is best...',
  confidence: 0.85
}

Full Documentation: See AGENT-TASK-SYSTEM.md


Development Commands

TDD Workflow

When implementing new features, follow this Test-Driven Development workflow:

  1. Write tests - Create comprehensive tests for the feature first (TDD approach)
  2. Commit tests - Commit the test suite before implementation
  3. Code implementation - Write the minimum code to pass the tests
  4. Iterate - Refactor and improve until all tests pass and code quality standards are met
  5. Commit implementation - Commit the working implementation

This ensures:

Build & Development

# Serve main application
npx nx serve gograb-space

# Build for production
npx nx build gograb-space

# Build all libraries
npx nx run-many -t build

# Run tests
npx nx test <project-name>
npx nx run-many -t test

# Lint code
npx nx lint <project-name>
npx nx run-many -t lint

# Show project details
npx nx show project <project-name>

# Visualize project graph
npx nx graph

Library Management

For the monorepo "editor" - skip this section and prioritize the analysis of the data in this file: LIBRARY MANAGEMENT

# Generate new Angular library
npx nx g @nx/angular:lib <lib-name> --directory=libs/core

# Generate new Angular component
npx nx g @nx/angular:component <component-name> --project=<project-name>

# Generate new service
npx nx g @nx/angular:service <service-name> --project=<project-name>

Architecture Overview

GoGrab Space is a modular Angular 20 monorepo built with Nx, designed as a multi-tenant platform with dynamic module loading and event-driven architecture.

Key Technologies

Core Principles

NX Monorepo Structure

Development Rules

Project Structure

apps/gograb-space/          # Main Angular application
libs/core/                  # Core system libraries
  ├── utilities/            # Cross-cutting utilities (@gograb-space/utilities)
  ├── log-system/          # Logging system (@libs-core/log-system)
  ├── event-system/        # Event bus (@libs-core/event-system)
  ├── module-base/         # Module contracts (@libs-core/module-base)
  ├── ui-framework/        # Design system (@libs-core/ui-framework)
  └── security/            # Auth & authorization (@libs-core/security)

Core Libraries

@gograb-space/utilities - Foundation utilities ✅ Completado

@libs-core/log-system - Comprehensive logging ✅ Completado (MVP)

@libs-core/event-system - Event-driven communication ✅ Completado

@libs-core/security - Security infrastructure ✅ Completado

@libs-core/module-base - Module contracts ✅ Completado

@libs-core/module-integrator - Module orchestration ✅ Completado

@libs-core/shared-models - Shared models ✅ Completado

@libs-core/mock-api - API mocking system ✅ Completado

@libs-core/action-registry - Command pattern ✅ Completado

@libs-core/data-access - Data access layer ✅ Completado

@libs-core/data-binding - Data binding system ✅ Completado (MVP)

@libs-core/ui-framework - Design system ✅ Completado

@gograb-space/user-management - User management module ✅ Completado

Development Standards

Code Generation Principles

CORE DIRECTIVE: Generate ONLY what is requested. No extra code, no placeholders, no TODOs.

ANGULAR ONLY: Generate exclusively Angular code. This project and all libraries run in the browser.

Minimal & Necessary Code

Angular 20 Features

State Management Hierarchy

This project follows a strict hierarchy for state management based on scope and complexity:

1. Signals (Preferred - Default Choice) 🎯

Use for:

Examples:

// ✅ Component state
export class CounterComponent {
  count = signal(0);
  doubled = computed(() => this.count() * 2);

  increment() {
    this.count.update(v => v + 1);
  }

  // Effects for side effects
  constructor() {
    effect(() => {
      console.log('Count changed:', this.count());
    });
  }
}

// ✅ Service state
export class UserPreferencesService {
  private themeSignal = signal<'light' | 'dark'>('light');
  theme = this.themeSignal.asReadonly();

  setTheme(theme: 'light' | 'dark') {
    this.themeSignal.set(theme);
  }
}

2. RxJS (Asynchronous Operations)

Use for:

Examples:

// ✅ HTTP operations
export class DataService {
  private http = inject(HttpClient);

  getData(): Observable<Data> {
    return this.http.get<Data>('/api/data').pipe(
      retry(2),
      timeout(5000),
      catchError(this.handleError)
    );
  }

  // ✅ Complex async workflows
  searchWithDebounce(searchTerm$: Observable<string>): Observable<Result[]> {
    return searchTerm$.pipe(
      debounceTime(300),
      distinctUntilChanged(),
      switchMap(term => this.search(term)),
      catchError(() => of([]))
    );
  }
}

// ✅ Event streams
export class FormComponent {
  private destroyRef = inject(DestroyRef);

  ngOnInit() {
    fromEvent(this.input.nativeElement, 'input')
      .pipe(
        debounceTime(300),
        map((event: Event) => (event.target as HTMLInputElement).value),
        takeUntilDestroyed(this.destroyRef)
      )
      .subscribe(value => this.handleInput(value));
  }
}

3. NGXS (High-Level Components Only)

Use ONLY for:

DO NOT use for:

Examples:

// ✅ Global auth state (HIGH-LEVEL)
@State<AuthStateModel>({
  name: 'auth',
  defaults: {
    user: null,
    token: null,
    isAuthenticated: false
  }
})
export class AuthState {
  @Action(Login)
  login(ctx: StateContext<AuthStateModel>, action: Login) {
    return this.authService.login(action.credentials).pipe(
      tap(result => {
        ctx.patchState({
          user: result.user,
          token: result.token,
          isAuthenticated: true
        });
      })
    );
  }
}

// ✅ Application-level tenant context (HIGH-LEVEL)
@State<TenantStateModel>({
  name: 'tenant',
  defaults: { currentTenant: null }
})
export class TenantState { ... }

// ❌ WRONG - Don't use NGXS for component state
@Select(UserState.firstName) firstName$!: Observable<string>; // Use Signal instead

Anti-Patterns to Avoid

// ❌ NO Promises - Always use RxJS
async getData() {
  const data = await fetch('/api/data');
  return data.json();
}

// ✅ YES - RxJS Observable
getData(): Observable<Data> {
  return this.http.get<Data>('/api/data');
}

// ❌ NO NGXS for local state
export class UserCardComponent {
  @Select(UserState.firstName) firstName$!: Observable<string>;
}

// ✅ YES - Signal for local state
export class UserCardComponent {
  firstName = input.required<string>();
  // or if managing locally:
  firstName = signal('');
}

// ❌ NO Signals for async operations
userClick = signal(null); // Then manually handling async

// ✅ YES - RxJS for async
userClick$ = fromEvent(button, 'click').pipe(
  switchMap(() => this.loadData())
);

// ❌ NO setTimeout
setTimeout(() => this.doSomething(), 1000);

// ✅ YES - RxJS timer (in production code)
timer(1000).pipe(
  takeUntilDestroyed(this.destroyRef)
).subscribe(() => this.doSomething());

// ⚠️ EXCEPTION - setTimeout ONLY in tests
it('should handle delay', (done) => {
  setTimeout(() => {
    expect(component.value).toBe(expected);
    done();
  }, 100);
});

Decision Tree

Need reactive state?
├─ Local to component/service?
│  └─ Use Signal ✅
├─ Async operation (HTTP, events, time-based)?
│  └─ Use RxJS ✅
├─ Global/cross-module state?
│  ├─ High-level (app/module)?
│  │  └─ Use NGXS ✅
│  └─ Low-level (component)?
│     └─ Use Signal + Injectable Service ✅
└─ Simple derived value?
   └─ Use computed() Signal ✅

Code Quality

Testing Requirements

Multi-Tenant Considerations

Barrel Exports

Always update barrel exports in src/index.ts when adding new modules:

// Add to appropriate index.ts
export * from './lib/new-feature/new-feature';

Library Dependencies

Core libraries have the following dependency hierarchy:

  1. utilities - no dependencies (foundation)
  2. shared-models - no dependencies (pure models)
  3. log-system - depends on utilities
  4. event-system - depends on utilities, log-system
  5. security - depends on utilities, log-system, shared-models
  6. module-base - depends on utilities, log-system, event-system, security
  7. module-integrator - depends on module-base, security, log-system, event-system, utilities
  8. action-registry - depends on security, log-system, event-system, utilities
  9. data-access - depends on security, log-system, event-system, mock-api, utilities
  10. data-binding - depends on utilities, log-system, shared-models, security (ContextService)
  11. mock-api - depends on utilities, log-system
  12. ui-framework - depends on log-system, event-system (minimal)
  13. user-management - depends on security, ui-framework, data-access, shared-models, log-system, event-system

Development Phase Notes

Workspace Configuration

When developing, always check existing implementations in similar modules before creating new functionality to maintain consistency and reuse existing patterns.


📚 Technical Documentation References

This section provides comprehensive references to technical documentation for AI code generators. These references are optional but highly recommended for informed decision-making during development, refactoring, or architectural changes.

📖 How to Use This Documentation

For AI Code Generators (like Claude Code):

Documentation Priority:

  1. 📖 README.md - High-level overview and quick reference
  2. 📋 requirements.md - Functional and non-functional requirements
  3. 🎨 design.md - Architectural decisions and technical design
  4. ✅ tasks.md - Implementation tasks and progress tracking

📦 Core Libraries Documentation

Action Registry.md (@libs-core/action-registry.md)

Key Topics: [Auto-generated - requires manual curation]


Data Access.md (@libs-core/data-access.md)

Key Topics: [Auto-generated - requires manual curation]


Data Binding (@libs-core/data-binding)

Key Topics: Data binding system, parameter resolution, source resolvers (manual, repository, config), binding configurator UI, widget configuration, action parameter binding, Singularity preparation, type-safe bindings, Observable resolution, ParameterMetadata extension


Event System.md (@libs-core/event-system.md)

Key Topics: [Auto-generated - requires manual curation]


Log System.md (@libs-core/log-system.md)

Key Topics: [Auto-generated - requires manual curation]


Module Base (@libs-core/module-base)

Key Topics: [Auto-generated - requires manual curation]


Module Base Plan.md (@libs-core/module-base-plan.md)

Key Topics: [Auto-generated - requires manual curation]


Module Base.md (@libs-core/module-base.md)

Key Topics: [Auto-generated - requires manual curation]


Module Integrator (@libs-core/module-integrator)

Key Topics: [Auto-generated - requires manual curation]


Module Integrator Plan.md (@libs-core/module-integrator-plan.md)

Key Topics: [Auto-generated - requires manual curation]


Module Integrator.md (@libs-core/module-integrator.md)

Key Topics: [Auto-generated - requires manual curation]


Security (@libs-core/security)

Key Topics: [Auto-generated - requires manual curation]


Security Updated Plan.md (@libs-core/security-updated-plan.md)

Key Topics: [Auto-generated - requires manual curation]


Security.md (@libs-core/security.md)

Key Topics: [Auto-generated - requires manual curation]


Shared Models Plan.md (@libs-core/shared-models-plan.md)

Key Topics: [Auto-generated - requires manual curation]


Shared Models.md (@libs-core/shared-models.md)

Key Topics: [Auto-generated - requires manual curation]


UI Framework (@libs-core/ui-framework)

Key Topics: [Auto-generated - requires manual curation]


Ui Framework.md (@libs-core/ui-framework.md)

Key Topics: [Auto-generated - requires manual curation]


Utilities.md (@gograb-space/utilities.md)

Key Topics: [Auto-generated - requires manual curation]


🧩 Business Modules Documentation

Analytics

Key Topics: [Auto-generated - requires manual curation]


Product Catalog

Key Topics: [Auto-generated - requires manual curation]


User Management

Key Topics: [Auto-generated - requires manual curation]


🏗️ Project-Level Documentation

Must To Do

Topics: [Auto-generated - requires manual curation]


Project Desc

Topics: [Auto-generated - requires manual curation]


🔄 Automatic Documentation Discovery

To regenerate this documentation index automatically, use:

# Generate documentation map
npm run docs:map

# Or manually with:
node scripts/generate-docs-map.js

📝 Documentation Conventions

File Naming:

Documentation Structure:

docs/
├── libs/                    # Core library documentation
│   └── [library-name]/
│       ├── README.md        # Library overview
│       ├── requirements.md  # Requirements specification
│       ├── design.md        # Architecture and design
│       └── tasks.md         # Implementation tasks
├── modules/                 # Business module documentation
│   └── [module-name]/
│       ├── README.md        # Module overview
│       ├── requirements.md  # Module requirements
│       ├── design.md        # Module architecture
│       └── tasks.md         # Module tasks
└── [project-docs].md        # Project-level documentation

Last Documentation Update: 2025-10-07 Total Libraries Documented: 18 core libraries Total Modules Documented: 3 modules

General Guidelines for working with Nx