agentleFS
iota-uziota-uz/iota-sdk/AGENTS.md

iota-sdk

AGENTS.md471 starsChanged 30 days agoApache-2.0View on GitHub

Before adding a consumer workaround for shared SDK behavior, trace the SDK API, available extension points, and affected consumers. Fix a reusable capability or invariant in the SDK; when a consumer exposed the defect, validate the fix in that consumer's preview workflow. Keep product-specific policy and workflow in the consumer. Decide from the actual ownership boundary, not from which repository first exposed the defect. Each module follows a strict Domain-Driven Design (DDD) pattern with clear layer separation:

We split this AGENTS.md into the rules it gives an agent

45 rules. About 0 are common, 8 are distinctive, and 37 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 37

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    DO NOT COMMENT EXECESSIVELY.

    line 4
  2. Distinctive:

    Prefer interfaces over concrete structs at boundaries

    line 9
  3. Distinctive:

    Keep domain and services decoupled from infrastructure details

    line 11
  4. Distinctive:

    Before adding a consumer workaround for shared SDK behavior, trace the SDK API, available extension points, and affected consumers.

    line 15
  5. Very specific:

    Create domain entity in modules/{module}/domain/aggregates/{entity_name}/

    line 73
  6. Very specific:

    Follow existing patterns (see payment_category or expense_category)

    line 75
  7. Very specific:

    Add database model to modules/{module}/infrastructure/persistence/models/models.go

    line 78
  8. Very specific:

    Create repository implementation in modules/{module}/infrastructure/persistence/{entity_name}_repository.go

    line 79
  9. Very specific:

    Add domain-to-database mappers in modules/{module}/infrastructure/persistence/{module}_mappers.go

    line 80
  10. Very specific:

    Create service in modules/{module}/services/{entity_name}_service.go

    line 83
  11. Very specific:

    Follow constructor pattern: NewEntityService(repo, eventPublisher)

    line 85
  12. Very specific:

    Create DTOs in modules/{module}/presentation/controllers/dtos/{entity_name}_dto.go

    line 88
  13. Very specific:

    Create controller in modules/{module}/presentation/controllers/{entity_name}_controller.go

    line 89
  14. Very specific:

    Create viewmodel in modules/{module}/presentation/viewmodels/{entity_name}_viewmodel.go

    line 90
  15. Very specific:

    Add mapper in modules/{module}/presentation/mappers/mappers.go

    line 91
  16. Very specific:

    Create templ files in modules/{module}/presentation/templates/pages/{entity_name}/

    line 94
  17. Very specific:

    Run templ generate after creating/modifying .templ files

    line 96
  18. Very specific:

    Add translations to all locale files in modules/{module}/presentation/locales/

    line 99
  19. Very specific:

    Add navigation item to modules/{module}/links.go

    line 103
  20. Very specific:

    Use composition.ProvideFuncAs[Interface] when a constructor returns a concrete type but you want the provider keyed by an interface

    line 106
  21. Very specific:

    Add controllers with composition.ContributeControllersFunc(...) or composition.AddControllers(...) for pre-built instances

    line 107
  22. Very specific:

    Run go vet ./... to verify compilation

    line 112
  23. Very specific:

    Run templ generate && just css if templates were modified

    line 113
  24. Very specific:

    Multi-tenant isolation: Always include tenant_id in WHERE clauses

    line 124
  25. Very specific:

    Error handling: Use pkg/serrors - serrors.Wrap(op, err) pattern

    line 125
  26. Very specific:

    HTMX: Check htmx.IsHxRequest(r), use htmx.SetTrigger(w, "event", payload)

    line 126
  27. Very specific:

    DO NOT USE sed for file manipulation

    line 130
  28. Very specific:

    Every PR adds .changes/<name>.json with bump (none, patch, minor, or major) and a non-empty summary.

    line 137
  29. Distinctive:

    Do not push version tags manually.

    line 139
  30. Very specific:

    Check translation files: just check tr

    line 150
  31. Very specific:

    After changes to css or .templ files: templ generate && just css

    line 153
  32. Very specific:

    After changes to Go code: go vet ./...

    line 154
  33. Very specific:

    Never run go build: - use go vet instead

    line 155
  34. Very specific:

    Run all tests: just test -v or go test -v ./...

    line 156
  35. Very specific:

    Run single test: go test -v ./path/to/package -run TestName

    line 157
  36. Very specific:

    Run specific subtest: go test -v ./path/to/package -run TestName/SubtestName

    line 158
  37. Distinctive:

    Read docs/agent-sign-in.md for setup, controller registration, and consumer CLI integration.

    line 172
  38. Very specific:

    Use go fmt for formatting.

    line 185
  39. Distinctive:

    Use Go v1.24.10 and follow standard Go idioms

    line 186
  40. Very specific:

    When writing a mapper function, always use utilities from pkg/mapping to ensure consistency

    line 191
  41. Distinctive:

    Follow existing patterns for database operations with jmoiron/sqlx

    line 193
  42. Very specific:

    Use pkg/htmx for all UI interactions

    line 198
  43. Very specific:

    Use existing components from components/ package before creating new ones

    line 199
  44. Very specific:

    Use htmx.IsHxRequest(r) to check if a request is from HTMX

    line 202
  45. Very specific:

    Use htmx.SetTrigger(w, "eventName", payload) for setting HTMX response triggers

    line 203

≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md - IOTA SDK Guide

Overview

DO NOT COMMENT EXECESSIVELY. Instead, write clear and concise code that is self-explanatory.

Design Philosophy

iota-sdk is a general purpose ERP building engine/solution. When designing anything inside iota-sdk:

  • Make it extensible, generalizable, and customizable
  • Prefer interfaces over concrete structs at boundaries
  • Apply dependency inversion and inject interfaces
  • Keep domain and services decoupled from infrastructure details

SDK and consumer ownership

Before adding a consumer workaround for shared SDK behavior, trace the SDK API, available extension points, and affected consumers. Fix a reusable capability or invariant in the SDK; when a consumer exposed the defect, validate the fix in that consumer's preview workflow. Keep product-specific policy and workflow in the consumer. Decide from the actual ownership boundary, not from which repository first exposed the defect.

Module Architecture

Each module follows a strict Domain-Driven Design (DDD) pattern with clear layer separation:

modules/{module}/
├── domain/                     # Pure business logic
│   ├── aggregates/{entity}/    # Complex business entities
│   │   ├── {entity}.go         # Entity interface
│   │   ├── {entity}_impl.go    # Entity implementation
│   │   ├── {entity}_events.go  # Domain events
│   │   └── {entity}_repository.go # Repository interface
│   ├── entities/{entity}/      # Simpler domain entities
│   └── value_objects/          # Immutable domain concepts
├── infrastructure/             # External concerns
│   └── persistence/
│       ├── models/models.go    # Database models
│       ├── {entity}_repository.go # Repository implementations
│       ├── {module}_mappers.go # Domain-to-DB mapping
│       ├── schema/{module}-schema.sql # SQL schema
│       └── setup_test.go       # Test utilities
├── services/                   # Business logic orchestration
│   ├── {entity}_service.go     # Service implementation
│   ├── {entity}_service_test.go # Service tests
│   └── setup_test.go           # Test setup
├── presentation/               # UI and API layer
│   ├── controllers/
│   │   ├── {entity}_controller.go # HTTP handlers
│   │   ├── {entity}_controller_test.go # Controller tests
│   │   ├── dtos/{entity}_dto.go # Data transfer objects
│   │   └── setup_test.go       # Test utilities
│   ├── templates/
│   │   ├── pages/{entity}/     # Entity-specific pages
│   │   │   ├── list.templ      # List view
│   │   │   ├── edit.templ      # Edit form
│   │   │   └── new.templ       # Create form
│   │   └── components/         # Reusable UI components
│   ├── viewmodels/             # Presentation models
│   ├── mappers/mappers.go      # Domain-to-presentation mapping
│   └── locales/                # Internationalization
│       ├── en.json             # English translations
│       ├── ru.json             # Russian translations
│       └── uz.json             # Uzbek translations
├── module.go                   # Module registration
├── links.go                    # Navigation items
└── permissions/constants.go    # RBAC permissions

Creating New Entities (Repositories, Services, Controllers)

1. Domain Layer

  • Create domain entity in modules/{module}/domain/aggregates/{entity_name}/
  • Define repository interface with CRUD operations and domain events
  • Follow existing patterns (see payment_category or expense_category)

2. Infrastructure Layer

  • Add database model to modules/{module}/infrastructure/persistence/models/models.go
  • Create repository implementation in modules/{module}/infrastructure/persistence/{entity_name}_repository.go
  • Add domain-to-database mappers in modules/{module}/infrastructure/persistence/{module}_mappers.go

3. Service Layer

  • Create service in modules/{module}/services/{entity_name}_service.go
  • Include event publishing and business logic methods
  • Follow constructor pattern: NewEntityService(repo, eventPublisher)

4. Presentation Layer

  • Create DTOs in modules/{module}/presentation/controllers/dtos/{entity_name}_dto.go
  • Create controller in modules/{module}/presentation/controllers/{entity_name}_controller.go
  • Create viewmodel in modules/{module}/presentation/viewmodels/{entity_name}_viewmodel.go
  • Add mapper in modules/{module}/presentation/mappers/mappers.go

5. Templates (if needed)

  • Create templ files in modules/{module}/presentation/templates/pages/{entity_name}/
  • Common templates: list.templ, edit.templ, new.templ
  • Run templ generate after creating/modifying .templ files

6. Localization

  • Add translations to all locale files in modules/{module}/presentation/locales/
  • Include NavigationLinks, Meta (titles), List, and Single sections

7. Registration

  • Add navigation item to modules/{module}/links.go
  • Register the module in modules/{module}/component.go:
    • Register repositories and services with composition.ProvideFunc(...) — the reflection injector resolves each constructor parameter from the container by type (no manual lookup)
    • Use composition.ProvideFuncAs[Interface] when a constructor returns a concrete type but you want the provider keyed by an interface
    • Add controllers with composition.ContributeControllersFunc(...) or composition.AddControllers(...) for pre-built instances
    • Attach static contributions via composition.AddNavItems, composition.AddQuickLinks, composition.AddHashFS
    • Declare locale files on the component itself via the required LocaleFS() method; the engine wires them automatically.

8. Verification

  • Run go vet ./... to verify compilation
  • Run templ generate && just css if templates were modified

Technology Stack

  • Backend: Go 1.24.10, IOTA SDK framework, GraphQL
  • Database: PostgreSQL 13+ (multi-tenant with organization_id)
  • Frontend: HTMX + Alpine.js + Templ + Tailwind CSS
  • Auth: Cookie-based sessions with RBAC

Core Rules

  • Multi-tenant isolation: Always include tenant_id in WHERE clauses
  • Error handling: Use pkg/serrors - serrors.Wrap(op, err) pattern
  • HTMX: Check htmx.IsHxRequest(r), use htmx.SetTrigger(w, "event", payload)
  • Templ: Edit .templ sources, not generated *_templ.go files. Inspect generated diffs or compiler errors when validating a change, and exclude unrelated generator churn.

Tool Use

  • DO NOT USE sed for file manipulation
  • For code navigation, use symbol references/definitions when available; use rg --files for paths and rg for text.

Build/Lint/Test Commands

SDK release workflow

Every PR adds .changes/<name>.json with bump (none, patch, minor, or major) and a non-empty summary. Existing declarations are append-only. Do not push version tags manually. PRs run service-free checks; a consumer request runs full CI on an immutable candidate before publication. Use sdk-tools sdk use <SDK-PR> for preview and sdkctl promote to wait for a verified release and update local production dependencies. See docs/sdk-releases.md.

Quality commands

Code Quality Commands:

  • Format Go code and templates: just fix fmt
  • Organize and format Go imports: just fix imports
  • Lint code (check unused variables/functions): just check lint
  • Check translation files: just check tr

Other Commands:

  • After changes to css or .templ files: templ generate && just css
  • After changes to Go code: go vet ./...
  • Never run go build - use go vet instead
  • Run all tests: just test -v or go test -v ./...
  • Run single test: go test -v ./path/to/package -run TestName
  • Run specific subtest: go test -v ./path/to/package -run TestName/SubtestName
  • Apply migrations: just db migrate up

Local browser sign-in for agents

For manual browser verification against a local development database, use the SDK's agent sign-in --user <ID-or-email> --next /internal/path --output json CLI command and open the returned URL in the agent's browser within one minute. Each link works once; issue a fresh one for retries or another account. Choose an existing user with the roles required by the task; their permissions remain unchanged.

Both CLI and server require -tags dev, APP_ENVIRONMENT=development, and AGENT_SIGNIN_ENABLED=true, the same OS user, loopback origin and tenant. Read docs/agent-sign-in.md for setup, controller registration, and consumer CLI integration. Use this flow only for local development.

E2E Testing

just e2e run      # Interactive UI mode
just e2e ci       # Headless CI mode
cd e2e && npx playwright test tests/module/specific.spec.ts  # Single test

Code Style Guidelines

  • Use go fmt for formatting. Do not indent code manually.
  • Use Go v1.24.10 and follow standard Go idioms
  • File organization: group related functionality in modules/ or pkg/ directories
  • Naming: use camelCase for variables, PascalCase for exported functions/types
  • Testing: table-driven tests with descriptive names (TestFunctionName_Scenario), use the require and assert packages from github.com/stretchr/testify
  • Error handling: use pkg/serrors with pattern serrors.Wrap(op, err) for standard error types
  • When writing a mapper function, always use utilities from pkg/mapping to ensure consistency
  • Type safety: use strong typing and avoid interface{} where possible
  • Follow existing patterns for database operations with jmoiron/sqlx
  • For UI components, follow the existing templ/htmx patterns

UI Implementation Guidelines

  • Use pkg/htmx for all UI interactions
  • Use existing components from components/ package before creating new ones

HTMX Best Practices

  • Use htmx.IsHxRequest(r) to check if a request is from HTMX
  • Use htmx.SetTrigger(w, "eventName", payload) for setting HTMX response triggers

Download now (ZIP)

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository6 other files it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.