packmind / packages
AGENTS.md317 starsChanged 2 months agoApache-2.0View on GitHub
This directory contains reusable domain and infrastructure packages shared across applications. Example packages: types, logger, accounts, standards, ui, node-utils, test-utils Before starting your work, make sure to review the coding standards relevant to your current task. Always consult the sections that apply to the technology, framework, or type of contribution you are working on. All rules and guidelines defined in these standards are mandatory and must be followed consistently. Failure to follow these standards may lead to inconsistencies, errors, or…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 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 repository92 other files it gives its agents.
- AGENTS.mdAGENTS.md
- apps/AGENTS.mdAGENTS.md
- apps/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- packages/CLAUDE.mdCLAUDE.md
- .cursor/rules/packmind/standard-backend-tests-redaction.mdcCursor rule
- .cursor/rules/packmind/standard-changelog.mdcCursor rule
- .cursor/rules/packmind/standard-code-comments.mdcCursor rule
- .cursor/rules/packmind/standard-compliance-logging-personal-information.mdcCursor rule
- .cursor/rules/packmind/standard-typescript-good-practices.mdcCursor rule
- agent-skill-frontmatter-auditSkill
- amplitude-listener-events-adoptionSkill
- cli-e2e-test-authoringSkill
- datadog-analysisSkill
- doc-auditSkill
- feature-specSkill
- feature-sprintSkill
- packmind-onboardSkill
- packmind-update-playbookSkill
- playbook-cli-auditSkill
- product-mapSkill
- qa-reviewSkill
- release-proprietarySkill
- upgrade-runtime-stackSkill
- working-with-playground-appSkill
- working-with-pm-design-kitSkill
- agentic-design-sessionSkill
- agentic-doc-ingestSkill
- agentic-feature-framingSkill
- agentic-orchestratorSkill
- agent-skill-frontmatter-auditSkill
- amplitude-listener-events-adoptionSkill
- cli-e2e-test-authoringSkill
- create-run-e2e-testsSkill
- creating-end-user-documentation-for-packmindSkill
- datadog-analysisSkill
- doc-auditSkill
- feature-flags-auditSkill
- feature-flags-authoringSkill
- feature-specSkill
- feature-sprintSkill
- how-to-write-typeorm-migrations-in-packmindSkill
- improve-claude-mdSkill
- packmind-onboardSkill
- packmind-update-playbookSkill
- playbook-cli-auditSkill
- product-mapSkill
- qa-reviewSkill
- release-proprietarySkill
- upgrade-runtime-stackSkill
- working-with-playground-appSkill
- working-with-pm-design-kitSkill
- agent-skill-frontmatter-auditSkill
- amplitude-listener-events-adoptionSkill
- cli-e2e-test-authoringSkill
- creating-end-user-documentation-for-packmindSkill
- datadog-analysisSkill
- doc-auditSkill
- feature-flags-auditSkill
- feature-flags-authoringSkill
- The first 60 shown.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
26 rules. About 0 are common, 12 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
test-utils: - Test factories, fixtures, and utilities for consistent test data creation
- Very specific: line 50
Test a package: ./node_modules/.bin/nx test <package-name>
- Distinctive: line 58
Before starting your work, make sure to review the coding standards relevant to your current task.
- Distinctive: line 60
Always consult the sections that apply to the technology, framework, or type of contribution you are working on.
- Distinctive: line 62
All rules and guidelines defined in these standards are mandatory and must be followed consistently.
- Distinctive: line 70
Use IN clause with array parameterization for filtering by multiple values.
- Distinctive: line 71
Use TypeORM's QueryBuilder with parameterized queries instead of raw SQL strings.
- Distinctive: line 78
Avoid excessive logger.debug in production code.
- Distinctive: line 82
Keep all import statements at the top of the file before any other code.
- Very specific: line 92
Never add an upstream kind to DomainErrorKind: upstream_rate_limited answers 429 and stays an UpstreamError, because the axis is fault, not …
- Very specific: line 93
Never log an error you rethrow: the filter records every thrown failure once, with its level, stack and typed context.
- Very specific: line 94
Never map domain errors in a controller with instanceof and a Nest HttpException.
- Very specific: line 95
Never throw new Error(...) from a use case.
- Very specific: line 98
Put resource ids in the error's context, never in a message: an upstream error's message reaches the caller, an internal error's never does.
- Very specific: line 101
Use kind: 'not_found' when a resource belongs to another tenant.
- Very specific: line 114
Use eventEmitterService.emit(new MyEvent(payload)) to emit events
- Very specific: line 115
Use static override readonly eventName with domain.entity.action pattern
- Very specific: line 116
Use this.subscribe(EventClass, this.handlerMethod) to register handlers
- Very specific: line 117
Use arrow functions for handlers to preserve this binding
- Very specific: line 127
Import only port interfaces from @packmind/types in consumer domain Hexas, allowing direct imports of provider Hexa classes only for …
- Distinctive: line 128
Use async initialize methods for deferred cross-domain dependencies by implementing an async initialize() method on the HexaFactory when a …
- Very specific: line 137
Do not override findById in scoped repositories — the base class handles soft delete via QueryOption.includeDeleted
- Distinctive: line 139
Test cross-scope isolation for every finder method returning collections
- Very specific: line 140
Use createScopedQueryBuilder(spaceId) or createScopedQueryBuilder(organizationId) for all finder methods in scoped repositories
- Distinctive: line 156
Never directly call Repositories in Adapter classes, repos must be called from Use Cases
- Distinctive: line 157
Never spread commands as multiple arguments in hexagon or UseCase classes.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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.
Files
Packages
This directory contains reusable domain and infrastructure packages shared across applications.
Package Categories
Core Infrastructure
- types - Shared TypeScript types and interfaces used across packages and apps
- logger - Logging utilities with console and structured output support
- node-utils - Node.js utility functions for file system, path manipulation, and common operations
- test-utils - Test factories, fixtures, and utilities for consistent test data creation
- migrations - TypeORM database migrations for schema evolution
Domain Packages
- accounts - User account management, authentication, and user profiles
- spaces - Workspace management, space members, roles, and permissions
- standards - Coding standards creation, storage, and retrieval
- recipes - Multi-step coding recipe definitions and execution
- skills - AI agent skill definitions and management
- editions - Product edition management (OSS, Enterprise, etc.)
Integration & Deployment
- git - Git repository operations for standards and recipe deployment
- deployments - Deployment pipeline for distributing standards, recipes, and skills to AI agents
- coding-agent - AI coding agent integration and rendering for multiple agent types (Claude Code, Cursor, etc.)
Language Analysis
- linter-ast - Abstract syntax tree (AST) analysis and manipulation utilities
- linter-execution - Linting rule execution engine for coding standards
- llm - Large language model integration for AI-powered features
Frontend
- frontend - Shared frontend utilities, hooks, and contexts
- ui - Reusable UI components with Chakra UI (PM-prefixed components)
Supporting
- assets - Static assets, WASM files, and embedded resources
Working with Packages
Common Nx Commands
- Build a package:
./node_modules/.bin/nx build <package-name> - Test a package:
./node_modules/.bin/nx test <package-name> - Lint a package:
./node_modules/.bin/nx lint <package-name>
Example packages: types, logger, accounts, standards, ui, node-utils, test-utils
<!-- start: Packmind standards -->Packmind Standards
Before starting your work, make sure to review the coding standards relevant to your current task.
Always consult the sections that apply to the technology, framework, or type of contribution you are working on.
All rules and guidelines defined in these standards are mandatory and must be followed consistently.
Failure to follow these standards may lead to inconsistencies, errors, or rework. Treat them as the source of truth for how code should be written, structured, and maintained.
Standard: Back-end repositories SQL queries using TypeORM
This standard provides guidelines for writing SQL queries using TypeORM in back-end repositories located in /infra/repositories/*Repository.ts. TypeORM offers multiple approaches to query data, but f... :
- Handle soft-deleted entities properly using withDeleted() or includeDeleted options. Always respect the QueryOption parameter when provided, and only include deleted entities when explicitly requested.
- Use IN clause with array parameterization for filtering by multiple values. Always pass arrays as spread parameters using :...paramName syntax to ensure proper parameterization.
- Use TypeORM's QueryBuilder with parameterized queries instead of raw SQL strings. Always pass parameters as objects to where(), andWhere(), and other query methods to prevent SQL injection and ensure type safety.
Full standard is available here for further request: Back-end repositories SQL queries using TypeORM
Standard: Back-end TypeScript Clean Code Practices
This standard establishes clean code practices in TypeScript for back-end development to enhance maintainability and ensure consistent patterns across services. It covers logging best practices, error... :
- Avoid excessive logger.debug in production code; use logger.info for important business events and logger.error only for failures nothing else records, adding logger.debug while debugging.
- Extend the package's
DomainError,PackmindInternalErrororPackmindUpstreamErrorbase when defining an error class; only a family base itself extendsError. - Inject PackmindLogger as a constructor parameter with a default value using a variable or a string representing the class name.
- Instantiate use cases in adapters without passing the adapter's logger; use cases must create their own logger for proper origin tracking.
- Keep all import statements at the top of the file before any other code. Never use dynamic imports in the middle of the code unless absolutely necessary for code splitting or lazy loading.
Full standard is available here for further request: Back-end TypeScript Clean Code Practices
Standard: Domain Error Handling
Failures raised by a use case are answered centrally by DomainExceptionFilter, which maps them to an HTTP status and a log level. A failure carrying no kind reaches Nest's ExceptionsHandler as a... :
- Classify a third-party HTTP failure from
error.response?.statusand its headers; never derive a status from a substring oferror.message. - Extend
PackmindInternalErrorfor broken invariants the caller cannot correct. - Give each package one base per error family it raises — domain, internal, upstream — each with a literal
reasonunion and a typedcontext. - Never add an upstream kind to
DomainErrorKind:upstream_rate_limitedanswers 429 and stays anUpstreamError, because the axis is fault, not status class. - Never log an error you rethrow: the filter records every thrown failure once, with its level, stack and typed
context. - Never map domain errors in a controller with
instanceofand a NestHttpException; the filter mapskindcentrally. - Never throw
new Error(...)from a use case; throw a class extending the package'sDomainError,PackmindInternalErrororPackmindUpstreamErrorbase. - Pass
retryAfterSecondson an upstream throttle when the provider said how long; the filter emits it as theRetry-Afterheader. - Pick the error family by fault: the caller's fault is a domain error, ours is
PackmindInternalError, a third party's isPackmindUpstreamError. - Put resource ids in the error's
context, never in a message: an upstream error's message reaches the caller, an internal error's never does. - Throw
upstream_unavailable(502, not 503) for an upstream outage, and for any upstream refusal the package does not yet model. - Throw a missing resource and a resource owned by another tenant from a single branch, with one error and one message.
- Use
kind: 'not_found'when a resource belongs to another tenant; reserveforbiddenfor when the caller's own rights are the subject.
Full standard is available here for further request: Domain Error Handling
Standard: Domain Events
Domain events enable communication between hexas without creating direct dependencies. Apply these rules when creating events, emitting them, or implementing listeners to react to events from other do... :
- Define event classes in
packages/types/src/{domain}/events/with anindex.tsbarrel file - Define payload as a separate
{EventName}Payloadinterface - Extend
PackmindListener<TAdapter>and implementregisterHandlers()to subscribe to events - Extend
UserEventfor user-triggered actions,SystemEventfor background/automated processes - Include
userIdandorganizationIdin UserEvent payloads; includeorganizationIdin SystemEvent payloads when applicable - Suffix event class names with
Event(e.g.,StandardUpdatedEvent) - Use
eventEmitterService.emit(new MyEvent(payload))to emit events - Use
static override readonly eventNamewithdomain.entity.actionpattern - Use
this.subscribe(EventClass, this.handlerMethod)to register handlers - Use arrow functions for handlers to preserve
thisbinding
Full standard is available here for further request: Domain Events
Standard: Port-Adapter Cross-Domain Integration
This standard defines how domain packages communicate with each other through the Port/Adapter pattern in our DDD monorepo architecture. By following these rules, you prevent circular dependencies, ma... :
- Declare all Command and Response types that define contracts between domains in packages/types/src/
<domain>/contracts/ to ensure a single source of truth and prevent import cycles between domain packages. - Define port interfaces in @packmind/types with domain-specific contracts that expose only the operations needed by consumers, where each method accepts a Command type and returns a Response type or domain entity.
- Expose adapters through public getter methods in the Hexa class that return the port interface implementation, as this is the only way external domains should access another domain's functionality.
- Import only port interfaces from @packmind/types in consumer domain Hexas, allowing direct imports of provider Hexa classes only for retrieving the adapter via the registry, but storing the reference typed as the port interface.
- Use async initialize methods for deferred cross-domain dependencies by implementing an async initialize() method on the HexaFactory when a domain needs dependencies that aren't available during construction, retrieving dependencies from the registry using isRegistered() checks before calling get().
Full standard is available here for further request: Port-Adapter Cross-Domain Integration
Standard: Scoped Repository Patterns
Enforce data isolation and consistent query patterns in repositories extending SpaceScopedRepository or OrganizationScopedRepository, ensuring tenant-safe data access across the Packmind codebase. :
- Declare
spaceIdororganizationIdas a required parameter on collection-returning interface methods not already narrowed by a tenant-owned parent id — never optional - Delegate write operations (
save,update) to the inheritedthis.add()method - Do not override
findByIdin scoped repositories — the base class handles soft delete viaQueryOption.includeDeleted - Justify every deliberately cross-tenant read with a comment naming the caller that requires it
- Test cross-scope isolation for every finder method returning collections
- Use
createScopedQueryBuilder(spaceId)orcreateScopedQueryBuilder(organizationId)for all finder methods in scoped repositories
Full standard is available here for further request: Scoped Repository Patterns
Standard: Use Case Architecture Patterns
This standard defines how to structure use cases in the Packmind monorepo following hexagonal architecture principles. Use cases represent the entry points to domain logic and must follow consistent p... :
- Accept commands as single parameters in adapter methods rather than multiple individual parameters to ensure consistency and easier parameter additions
- Define each use case contract in its own file at packages/types/src/{domain}/contracts/{UseCaseName}.ts with Command type, Response type, and UseCase interface exports
- Export exactly three type definitions from each use case contract file: {Name}Command for input parameters, {Name}Response for return value, and I{Name}UseCase as the interface combining both
- Extend AbstractAdminUseCase and implement executeForAdmins method for use cases requiring admin privileges, with automatic validation that the user is a member with admin role
- Extend AbstractMemberUseCase and implement executeForMembers method for organization-scoped use cases that do NOT operate within a specific space, with automatic user and organization validation
- Extend AbstractSpaceMemberUseCase and implement executeForSpaceMembers method for use cases operating within a specific space (command includes spaceId), with automatic user, organization, and space membership validation
- Extend PackmindCommand for authenticated use case commands that include userId and organizationId, or extend PublicPackmindCommand for public endpoints without authentication
- Extend SpaceMemberCommand instead of PackmindCommand for use case commands that include a spaceId to get both organizationId and spaceId typing
- Implement IPublicUseCase interface directly with an execute method for public use cases that don't require authentication, without extending any abstract use case class
- Never directly call Repositories in Adapter classes, repos must be called from Use Cases
- Never spread commands as multiple arguments in hexagon or UseCase classes; always pass the complete command object to maintain type safety and reduce errors
- Response and Commands must not be defined in the same file than the associated UseCase class
- Restrict use case classes to expose only the execute method for public use cases or executeForMembers/executeForAdmins methods for member/admin use cases, with no other public methods
- Reuse existing use cases through port/adapter interfaces instead of instantiating them directly within use cases
- UseCase must be associated with a Command and Response type
Full standard is available here for further request: Use Case Architecture Patterns
<!-- end: Packmind standards -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

