Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add commands/packmindhub/packmind/repository-implementation-and-testing-patterngit clone --depth 1 https://github.com/PackmindHub/packmindWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/commands/packmindhub/packmind/repository-implementation-and-testing-pattern)<a href="https://agentmods.dev/commands/packmindhub/packmind/repository-implementation-and-testing-pattern"><img src="https://agentmods.dev/badge/commands/packmindhub/packmind/repository-implementation-and-testing-pattern.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00005 | $0.01641 |
| Opus 5 | $0.00003 | $0.00821 |
| Sonnet 5 | $0.00001 | $0.00328 |
| Haiku 4.5 | $0.00001 | $0.00164 |
Grade A, and why
repository-implementation-and-testing-pattern scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 234 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Implement a standardized repository with soft delete functionality and comprehensive tests to ensure maintainable code and reliable data access patterns in the Packmind codebase.
When to Use
- When creating a new repository for an entity
- When you need to implement data access layer following Packmind patterns
- When writing comprehensive tests for repositories
- When implementing soft delete functionality
Context Validation Checkpoints
- Have you defined the entity and its TypeORM schema?
- Do you know which domain-specific finder methods are needed?
- Have you created a test factory for the entity?
- Is the AbstractRepository base class available in @packmind/shared?
Recipe Steps
Step 1: Define Repository Interface
Create the repository interface extending IRepository from @packmind/shared. Add domain-specific finder methods that will be needed by use cases.
import { Entity } from '../entities/Entity';
import { IRepository, QueryOption } from '@packmind/shared';
import { OrganizationId } from '@packmind/accounts';
export interface IEntityRepository extends IRepository<Entity> {
findBySlug(slug: string, opts?: QueryOption): Promise<Entity | null>;
findByOrganizationId(organizationId: OrganizationId): Promise<Entity[]>;
// Add other domain-specific finder methods
}
Step 2: Implement Repository Class
Create the repository class extending AbstractRepository. Implement the interface with proper logging for all operations. Override loggableEntity to specify which fields should be logged.
import { Entity } from '../../domain/entities/Entity';
import { IEntityRepository } from '../../domain/repositories/IEntityRepository';
import { EntitySchema } from '../schemas/EntitySchema';
import { Repository } from 'typeorm';
import {
PackmindLogger,
localDataSource,
AbstractRepository,
QueryOption,
} from '@packmind/shared';
import { OrganizationId } from '@packmind/accounts';
const origin = 'EntityRepository';
export class EntityRepository
extends AbstractRepository<Entity>
implements IEntityRepository
{
constructor(
repository: Repository<Entity> = localDataSource.getRepository<Entity>(EntitySchema),
logger: PackmindLogger = new PackmindLogger(origin),
) {
super('entity', repository, logger, EntitySchema);
this.logger.info('EntityRepository initialized');
}
protected override loggableEntity(entity: Entity): Partial<Entity> {
return {
id: entity.id,
name: entity.name, // Include key identifying fields only
};
}
async findBySlug(slug: string, opts?: QueryOption): Promise<Entity | null> {
this.logger.info('Finding entity by slug', { slug });
try {
const entity = await this.repository.findOne({
where: { slug },
withDeleted: opts?.includeDeleted ?? false,
});
if (entity) {
this.logger.info('Entity found by slug', { slug, entityId: entity.id });
} else {
this.logger.warn('Entity not found by slug', { slug });
}
return entity;
} catch (error) {
this.logger.error('Failed to find entity by slug', {
slug,
error: error instanceof Error ? error.message : String(error),
});
throw error;
}
}
}
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 234 lines · 5 tokens per session scan A 76e132ba0f6f
repository-implementation-and-testing-pattern is a command published in the GitHub repository PackmindHub/packmind (308 stars, last pushed today), licensed Apache-2.0. It adds 5 tokens to every session and 1,641 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other commands, from other repositories
check_schema_version
Check the Flyway schema version of the SQLite database on a Docker volume.
stats
Show token-saver compression statistics and savings.
data-architect
You are a rigorous data architect. You design schemas that scale, optimize queries that crawl, and normalize (or denormalize) with surgical precision. You do not accept "we'll optimize later" or "it works in dev" database design.
migration
You are the Database Migration Specialist, responsible for creating, testing, and managing database schema changes. You ensure migrations are safe, reversible, and tested.
cleanup
Detect and remove orphaned code, unused components, dead routes, and stale database artifacts.
migrate
Apply or rollback database migrations — auto-detects migration tool.