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.
git clone --depth 1 https://github.com/theimaginaryfoundation/what-iffWrote 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/rules/theimaginaryfoundation/what-iff/datastore)<a href="https://agentmods.dev/rules/theimaginaryfoundation/what-iff/datastore"><img src="https://agentmods.dev/badge/rules/theimaginaryfoundation/what-iff/datastore/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/theimaginaryfoundation/what-iff/datastore"><img src="https://agentmods.dev/badge/rules/theimaginaryfoundation/what-iff/datastore.svg" alt="Reviewed on agentmods" width="80" 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.1 | $0.00000 | $0.04008 |
| Opus 5 | $0.00000 | $0.02004 |
| Sonnet 5 | $0.00000 | $0.00802 |
| Haiku 4.5 | $0.00000 | $0.00401 |
Grade A, and why
datastore 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 — 599 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Datastore Implementation Guidelines
Overview
Our datastore layer uses Ent as the ORM and follows consistent patterns for data access. This document outlines the key patterns and best practices to follow when working with the datastore package.
General Architecture
- Package: All datastore code lives in the
internal/datastorepackage - Models: We use models from the
internal/modelspackage for input/output, never exposing Ent types directly - Client: The datastore uses an Ent client for database operations
- Logging: We use
zap.Loggerfor structured logging throughout the datastore
// Base Datastore struct
type Datastore struct {
dbClient *ent.Client
logger *zap.Logger
}
func NewDatastore(dbClient *ent.Client, logger *zap.Logger) *Datastore {
return &Datastore{
dbClient: dbClient,
logger: logger,
}
}
File Organization
Each entity type should have its own file in the datastore package. For example:
content_idea.go- Content idea based on trending news and posts related to a nichecontent_brief.go- A content development brief including SEO planinterview_question.go- An interview question and the user's response for content development
Standard Methods
Each entity type should implement the following standard methods:
- Model Conversion Function: Convert from Ent type to model type
// Convert from Ent entity to model
func toContentIdeaModel(e *ent.ContentIdea) *models.ContentIdea {
return &models.ContentIdea{
ID: e.ID,
ProjectID: e.Edges.Project.ID,
Title: e.Title,
Summary: e.Summary,
SourceURL: e.SourceURL,
Approved: e.Approved,
CreatedAt: e.CreatedAt,
UpdatedAt: e.UpdatedAt,
}
}
- Create Method: Single entity creation with transaction and authorization
func (d *Datastore) CreateContentIdea(ctx context.Context, userID uuid.UUID, contentIdea models.ContentIdea) (*models.ContentIdea, error) {
// Start transaction
tx, err := d.dbClient.Tx(ctx)
if err != nil {
d.logger.Error("failed to start transaction", zap.Error(err))
return nil, err
}
// Rollback in case of error
defer func() {
if v := recover(); v != nil {
tx.Rollback()
panic(v)
}
}()
// Check if project exists and belongs to the user
projectExists, err := tx.Project.Query().
Where(
project.ID(contentIdea.ProjectID),
project.HasOwnerWith(
user.ID(userID),
),
).
Exist(ctx)
if err != nil {
d.logger.Error("failed to query project", zap.Error(err))
if rerr := tx.Rollback(); rerr != nil {
d.logger.Error("failed to rollback transaction", zap.Error(rerr))
}
return nil, err
}
if !projectExists {
d.logger.Error("project not found or user not authorized",
zap.String("project_id", contentIdea.ProjectID.String()),
zap.String("user_id", userID.String()))
if rerr := tx.Rollback(); rerr != nil {
d.logger.Error("failed to rollback transaction", zap.Error(rerr))
}
return nil, ErrProjectNotFound
}
// Create entity
entContentIdea, err := tx.ContentIdea.Create().
SetTitle(contentIdea.Title).
SetSummary(contentIdea.Summary).
SetSourceURL(contentIdea.SourceURL).
SetApproved(contentIdea.Approved).
SetProjectID(contentIdea.ProjectID).
Save(ctx)
if err != nil {
d.logger.Error("failed to create content idea", zap.Error(err))
if rerr := tx.Rollback(); rerr != nil {
d.logger.Error("failed to rollback transaction", zap.Error(rerr))
}
return nil, err
}
// Load relationships needed for model conversion
entContentIdea, err = tx.ContentIdea.Query().
Where(contentidea.ID(entContentIdea.ID)).
WithProject().
Only(ctx)
if err != nil {
d.logger.Error("failed to load project relationship", zap.Error(err))
if rerr := tx.Rollback(); rerr != nil {
d.logger.Error("failed to rollback transaction", zap.Error(rerr))
}
return nil, err
}
// Commit transaction
if err := tx.Commit(); err != nil {
d.logger.Error("failed to commit transaction", zap.Error(err))
return nil, err
}
// Return model
return toContentIdeaModel(entContentIdea), nil
}
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 · 599 lines · 0 tokens per session scan A 07a5b4031db7
datastore is a cursor rule published in the GitHub repository theimaginaryfoundation/what-iff (15 stars, last pushed today), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 4,008 tokens. 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-09.
Other cursor rules, from other repositories
prefer-assertions-over-defensive-checks
Prefer assertions over defensive checks when data is guaranteed to be valid.
as-contract-cast-smell
// ❌ WRONG — bypasses the family ContractSerializer seam const contract = JSON.parse(raw) as Contract; const contract = JSON.parse(raw) as Contract .
no-backward-compatibility
Do not add backward-compatibility shims or migration scaffolding.
postgresql
This guide defines the definitive best practices for writing clean, performant, and maintainable PostgreSQL SQL, focusing on modern conventions and avoiding common pitfalls.
query-optimization
A database performance rule that requires measuring PostgreSQL queries with EXPLAIN ANALYZE under the same user permissions and row-level security (RLS) conditions used in production.
ehs-ims-conventions
EHS IMS app — RBAC, data layer, tRPC, migrations, AI boundaries.