agentleFS
golid-aigolid-ai/golid/.cursor/rules/plan-feature.mdc

golid / rules

Cursor rule40 starsChanged 6 months agoMITView on GitHub

Framework for planning a new feature end-to-end — use when asked to plan or design a new module

The file

We split this plan-feature.mdc into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

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

    Run workflow-routing before this rule so the plan's risk tier and process weight match the feature's blast radius.

    line 10
  2. Very specific:

    Use this structure when asked to plan or design a new feature/module.

    line 13
  3. Very specific:

    If a similar successful plan exists in docs/plans/ or docs/plans/archive/, cross-reference it for phasing, QA gates, rollback, and …

    line 22
  4. Distinctive:

    When a plan touches money math, authorization gates, subscriptions, legal state, or three or more modules, add these sections before …

    line 39

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule 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
plan-feature.mdc
---
description: Framework for planning a new feature end-to-end — use when asked to plan or design a new module
alwaysApply: false
---

# Plan a Feature

> **Thesis:** Plan the data model and permission model upfront. Everything else — API surface, frontend, tests — follows from those two decisions.

Run `workflow-routing` before this rule so the plan's risk tier and process
weight match the feature's blast radius.

Use this structure when asked to plan or design a new feature/module.
Save repo plans under `docs/plans/`; they become the execution input for
`slice-and-ship`. Module specs remain current-state truth, not future-plan
documents. Inherits the universal checklist and length guidance from
`planning-standards`.

**Check `docs/flows.md`** for existing cross-module flows that may be affected.
**Check `docs/dependency-graph.md`** for blast radius — which modules depend on
the one you're modifying. **Check `docs/permissions.md`** for authorization patterns.
If a similar successful plan exists in `docs/plans/` or `docs/plans/archive/`,
cross-reference it for phasing, QA gates, rollback, and pre-launch checklists.

## Planning Checklist

1. **Explore existing code** — read the schema, related services, frontend routes. Understand what exists.
2. **Scaffold boilerplate** — run `make new-module name=<module>` to generate migration, service, handler, and route stubs.
3. **Identify the data model** — what tables, enums, relationships are needed? Check if any already exist in `backend/migrations/000001_init.up.sql`. For every existing table/column/enum the plan references, cite migration:line. Include a "Schema Verification" section in the plan with the verified references; grep all migrations to populate it before writing any seed/migration SQL.
4. **Define goals and non-goals** — make the product boundary explicit before designing tables/routes.
5. **Define the API surface** — list every endpoint (verb + path + purpose) and verify route namespace against existing conventions (`/me/*` for caller-owned resources, module paths for shared resources).
6. **Identify auth requirements** — who can do what? Map to the two-layer pattern (handler: authn, service: authz).
7. **Note side effects** — what happens on status changes? Cascading updates? History entries?
8. **Plan seed data** — test accounts need realistic data for manual testing during development.
9. **Plan rollout** — define deploy gates, rollback/kill-switch posture, QA smoke checks, and any pre-launch checklist.

## Cross-Module / Money / Auth Plans

When a plan touches money math, authorization gates, subscriptions, legal state,
or three or more modules, add these sections before implementation:

- **Pre-Edit Search Checklist** — exact `rg` commands and expected findings for
  invoice creation, constraints, auth gates, admin surfaces, generated types, or
  other coupling points. Do not rely on memory for call-site discovery.
- **Invariants** — falsifiable post-conditions that must remain true after the
  change. Example: existing paid invoices calculate the same fee as before.
- **Rollback Posture** — what is additive, what is backwards-compatible, and
  what blocks rollback.
- **Manual QA Matrix** — scenario → expected result rows that anyone can run in
  QA/demo.
- **Contract Sync Targets** — name every OpenAPI schema, frontend API type,
  module spec, seed file, and rule/doc that must change with the slice.

These sections turn audit findings into executable gates. If an audit finds a
miss in one of these areas, update the plan before coding.

## Plan Structure (phases)

```
Phase 1: Database Migration
  - New enums, tables, ALTER existing tables
  - Down migration

Phase 1b: Seed Data (immediately after migration)
  - Enables manual testing during backend development

Phase 2: Backend Service
  - Types (input/output structs)
  - Auth helper (verifyXMembership)
  - CRUD methods + business logic

Phase 3: Backend Handler + Routes
  - Request types, validation
  - Handler methods
  - Route registration in `internal/wire/routes.go`

Phase 4: Frontend API Types + Client
  - TypeScript interfaces matching backend structs
  - API client object (itemsApi pattern)

Phase 5: Frontend Pages + Components
  - Sidebar nav entry
  - List page (with filters, empty states)
  - Detail view (modal or page)
```

## Key Decisions to Make Upfront

- **Goals / non-goals** — name what v1 does and what is intentionally deferred.
- **Modal vs page** for detail views — prefer modal for "detail within a list" (notes, items). Use page for standalone content.
- **Transaction boundaries** — identify which operations need multi-write transactions.
- **Permission model** — who can create/read/update/delete? Map to `verifyResourceAccess` or similar. See permissions mapping in `plan-feature-execution`.
- **Status side effects** — what happens on transitions? Auto-history? Cascading approvals?
- **Computed vs stored** — prefer computed fields (via SQL subquery) over stored aggregates.
- **Side effects** — what happens on key events? Emails, webhooks, audit logging?
- **Real-time updates** — for features that need server push (live notifications, collaborative edits), consider SSE. Exclude SSE endpoints from gzip and timeout middleware in `middleware/stack.go`.
- **User-generated content** — decide plaintext vs Markdown vs sanitized HTML, XSS posture, rate limits/throttles, duplicate-abuse controls, reports/moderation, and retention after account deletion.
- **Performance posture** — for derived sorts, computed counts, broad `ILIKE` search, or throttling `COUNT(*)` checks, name the expected index/query plan or explicitly accept low-volume sequential scans for v1. Do not invent observability gates the project does not have; use existing slow-query logs, `EXPLAIN ANALYZE`, or concrete test evidence.
- **Docs timing** — OpenAPI/module specs/permissions docs land with the slice that changes behavior, not in a final cleanup-only commit.

## Related Rules

- Execution readiness, critique loop, permissions — see `plan-feature-execution`.
- Universal checklist and length guidance — see `planning-standards`.
- Slicing and shipping — see `slice-and-ship`.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.