agentleFS
iota-uziota-uz/iota-sdk/.github/copilot-instructions.md

iota-sdk

Copilot instructions471 starsChanged 30 days agoApache-2.0View on GitHub

This document provides context and guidelines for GitHub Copilot when working on this codebase. Multi-tenant business management platform built on the IOTA SDK framework. Provides modular solutions for financial management, CRM, warehouse operations, project management, and HR functionality. Run these commands to verify code quality: Every database query MUST include tenant filtering: Use composables.UseTenantID(ctx) to get the current tenant ID. Always wrap errors with operation context: Use di.H pattern for all service dependencies:

We split this copilot-instructions.md into the rules it gives an agent

16 rules. About 1 is common, 6 are distinctive, and 9 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Multi-tenant: All data is isolated via organization_id - every query MUST include tenant filtering

    line 31
  2. Distinctive:

    Run these commands to verify code quality:

    line 60
  3. Distinctive:

    Every database query MUST include tenant filtering:

    line 93
  4. Very specific:

    Use composables.UseTenantID(ctx) to get the current tenant ID.

    line 103
  5. Common:

    Always wrap errors with operation context:

    line 107
  6. Very specific:

    Use di.H pattern for all service dependencies:

    line 118
  7. Very specific:

    Use composables.UseTx(ctx) for transactions

    line 132
  8. Distinctive:

    Use parameterized queries ($1, $2) - never string concatenation

    line 133
  9. Very specific:

    Use templ.URL() for dynamic URLs

    line 144
  10. Very specific:

    Never use @templ.Raw() with user input (XSS risk)

    line 145
  11. Very specific:

    Use CamelCase for form field names (e.g., FirstName, not first_name)

    line 147
  12. Very specific:

    Update all 3 locale files: en.toml, ru.toml, uz.toml

    line 151
  13. Distinctive:

    Avoid TOML reserved keywords (OTHER, ID, DESCRIPTION)

    line 152
  14. Distinctive:

    Use StatementBegin/StatementEnd for PL/pgSQL functions/triggers

    line 159
  15. Very specific:

    Always include organization_id with ON DELETE CASCADE for multi-tenant tables

    line 160
  16. Distinctive:

    Test reversibility: Up→Down→Up cycle

    line 161

≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions 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
copilot-instructions.md

IOTA SDK Multi-Tenant Business Management Platform

This document provides context and guidelines for GitHub Copilot when working on this codebase.

Project Overview

Multi-tenant business management platform built on the IOTA SDK framework. Provides modular solutions for financial management, CRM, warehouse operations, project management, and HR functionality.

Core Business Domains

  • Financial Management: Payments, expenses, debts, transactions, counterparties, money accounts
  • Customer Relations: Client management, communication, message templates
  • Warehouse Operations: Inventory, products, orders, positions, units
  • Project Management: Project tracking, stage management, task coordination
  • Human Resources: Employee management, organizational structure
  • Billing & Subscriptions: Payment processing, subscription management, Stripe integration

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
  • Payments: Stripe subscriptions

Architecture

Design Principles

  • DDD (Domain-Driven Design): Strict layer separation between domain, service, repository, and presentation
  • Multi-tenant: All data is isolated via organization_id - every query MUST include tenant filtering
  • HTMX-First: Server-side rendering with HTMX + Alpine.js + Templ
  • Dual Servers:
    • Main (cmd/server/main.go): Multi-tenant platform, all modules
    • SuperAdmin (cmd/superadmin/main.go): Admin-only server (port 4000)

Code Organization

modules/{module}/
  domain/
    aggregates/         # Domain entities
    */repository.go     # Repository interfaces
  presentation/
    controllers/{page}_controller.go
    viewmodels/{entity}_viewmodel.go
    templates/pages/{page}/
    locales/{lang}.toml
  services/{domain}_service.go
  infrastructure/persistence/{entity}_repository.go

Environment Branches

  • Production: main branch
  • Staging: staging branch

Verification Commands

Run these commands to verify code quality:

# Code Quality
go vet ./...                          # After Go changes (prefer over go build)
make check lint                       # Run golangci-lint
make check deadcode                   # Detect unreachable/unused code

# Testing (Note: Full test suite is SLOW - use sparingly)
go test -v ./path/to/package -run TestName  # Single test by name (fast)
make test                             # Run all tests
make test coverage                    # Run tests with coverage report

# Template & CSS
make generate                         # Generate templ templates
make css                              # Compile CSS with minification

# Migrations
make db migrate up                    # Apply migrations
make db migrate down                  # Rollback migrations

# Translations
make check tr                         # Validate translations

# E2E Tests
make e2e ci                           # Run Playwright E2E tests (headless)
make e2e run                          # Run Playwright E2E tests (UI mode)

Critical Code Rules

Multi-Tenant Isolation (CRITICAL)

Every database query MUST include tenant filtering:

// CORRECT - Always include organization_id
SELECT * FROM payments WHERE organization_id = $1 AND id = $2

// WRONG - Security vulnerability
SELECT * FROM payments WHERE id = $1

Use composables.UseTenantID(ctx) to get the current tenant ID.

Error Handling

Always wrap errors with operation context:

const op = serrors.Op("service.PaymentService.GetByID")
if err != nil {
    return nil, serrors.Wrap(op, err)
}

Dependency Injection

Use di.H pattern for all service dependencies:

func NewController(h di.H) *Controller {
    return &Controller{
        paymentService: di.Get[PaymentService](h),
    }
}

Repository Pattern

  • Interfaces in domain layer (modules/*/domain/*/repository.go)
  • Implementations in infrastructure (modules/*/infrastructure/persistence/*)
  • Use composables.UseTx(ctx) for transactions
  • Use parameterized queries ($1, $2) - never string concatenation

Controllers

  • Auth middleware via middleware.Authorize()
  • Form parsing: composables.UseForm[DTO](r)
  • Query params: composables.UseQuery[DTO](r)
  • HTMX helpers: Use pkg/htmx package functions

Templates (Templ)

  • Use templ.URL() for dynamic URLs
  • Never use @templ.Raw() with user input (XSS risk)
  • Include CSRF tokens in all forms
  • Use CamelCase for form field names (e.g., FirstName, not first_name)

Translations

  • Update all 3 locale files: en.toml, ru.toml, uz.toml
  • Avoid TOML reserved keywords (OTHER, ID, DESCRIPTION)
  • Validate with make check tr

Migrations

See .claude/guides/backend/migrations.md for comprehensive patterns. Key rules:

  • Include both Up and Down sections (Down must reverse Up)
  • Use StatementBegin/StatementEnd for PL/pgSQL functions/triggers
  • Always include organization_id with ON DELETE CASCADE for multi-tenant tables
  • Test reversibility: Up→Down→Up cycle

Documentation

For detailed implementation patterns, see these guide files:

  • .claude/guides/backend/domain-service.md - DDD, services, entities
  • .claude/guides/backend/repository.md - Repository patterns, query optimization
  • .claude/guides/backend/testing.md - ITF testing framework
  • .claude/guides/backend/presentation.md - Controllers, ViewModels, templates
  • .claude/guides/backend/migrations.md - SQL migration patterns
  • .claude/guides/backend/i18n.md - Translation management
  • .claude/guides/backend/routing.md - Module registration, DI

Download now (ZIP)

  • Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.

    Of the Copilot instructions files we read, the 2,297 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.