Purely Internal Copilot Rules — Free CoPilot Rules Template
    Neura Market
    Neura Market
    /CoPilot
    Marketplace
    Directories
    Resources
    CoPilot
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeekCoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityPluginsTrending
    CoPilotRulesPurely Internal Copilot Rules
    Back to Rules

    Purely Internal Copilot Rules

    gkstrmtm July 19, 2026
    0 copies 0 downloads
    Rule Content
    # Purely Automation agent notes
    
    ## Big picture
    - The root app is a Next.js 16 App Router project; most feature logic lives in `src/lib/*`, while `src/app/*` mostly provides routes, pages, and thin API handlers.
    - `mobile-app/` is a separate Expo app with its own package.json, build, and deployment target. Never import root `src/*`, `@/*`, `next/*`, or Prisma code into `mobile-app/`.
    - Data lives in PostgreSQL via Prisma (`src/lib/db.ts`, `prisma/schema.prisma`). The schema is large and multi-product: internal ops, `/portal`, `/credit`, `/ads`, hosted funnels/forms, Connect, and Pura all share the same database.
    
    ## Routing and auth that are easy to break
    - Middleware is delegated through `middleware.ts` -> `src/lib/proxy.ts`. Read that file before changing auth, redirects, or custom-domain behavior.
    - `/portal` and `/credit` share most UI code, but they are separate session surfaces with different cookies (`pa.portal.session`, `pa.credit.session`) and an `x-portal-variant` header.
    - `/credit/*` is internally rewritten onto `/portal/*`; when adding portal APIs or links, preserve variant-aware behavior with helpers like `portalBasePath()` and `normalizePortalVariant()` from `src/lib/portalVariant.ts`.
    - `/ads` is a third auth surface with its own cookie (`pa.ads.session` in `src/lib/adsAuth.ts`). Do not collapse these session boundaries.
    - Customer custom domains are handled in `src/lib/proxy.ts` by rewriting non-platform hosts to `/domain-router/*`. Changes to routing must preserve this rewrite path.
    
    ## Database and migration safety
    - Use the shared Prisma client from `src/lib/db.ts`; imports should normally come from `@/lib/*` via the `@/*` alias in `tsconfig.json`.
    - Do not assume the deployed DB matches `schema.prisma`. This repo intentionally uses drift-hardening helpers such as `src/lib/dbSchemaCompat.ts` and runtime schema ensures like `src/lib/connectSchema.ts`.
    - Connect routes call `ensureConnectSchema()` before DB work so production does not break on partially applied migrations. Follow that pattern for schema-sensitive features.
    - `npm run db:push`, `npm run db:migrate`, and `npm run db:deploy` are guarded by `scripts/db-guard.mjs`. Remote Supabase mutations require explicit `ALLOW_PROD_DB_MUTATIONS=1`.
    - Many one-off schema updates are applied with idempotent scripts in `scripts/` rather than only with Prisma migrations. Reuse those patterns instead of adding unsafe ad hoc SQL.
    
    ## Feature organization patterns
    - Portal service definitions live in `src/app/portal/services/catalog.ts`; service-specific permissions, billing, and credits logic are centralized in `src/lib/portal*` modules.
    - Pura and portal AI behavior are implemented in `src/lib/pura*.ts`, `src/lib/portalSupportChat.ts`, and the very large `src/lib/portalAgentActionExecutor.ts`. Prefer extending shared planners/resolvers/executors over adding one-off route logic.
    - For portal/credit signup and auth flows, use the existing helpers in `src/lib/portalAuth.ts`, `src/lib/portalAccounts.ts`, and `src/app/api/auth/client-signup/route.ts` rather than inventing parallel cookie or owner-resolution logic.
    - Many API routes that mutate portal data export `runtime = "nodejs"`, `dynamic = "force-dynamic"`, and `revalidate = 0`; preserve those when editing request-time server logic.
    
    ## Workflows and validation
    - Use Node 20.x. Root commands: `npm run dev`, `npm run build`, `npm run lint`, `npx tsc --noEmit`, `npm run pura:production-smoke`.
    - `npm run lint` is not just ESLint: it also runs `scripts/check-no-em-dash.mjs`, which fails on em/en dashes inside tracked files under `src/` and `mobile-app/src/`.
    - The repo relies heavily on VS Code tasks and targeted QA scripts under `tmp/` and `scripts/` for reproductions and smoke tests. Prefer the narrowest existing task/script that matches the area you changed.
    - Mobile app commands are separate: `npm --prefix mobile-app run web`, `npm --prefix mobile-app run build`, `npm --prefix mobile-app run typecheck`.
    
    ## Project-specific rules
    - Keep changes surgical. This repo mixes public marketing pages, employee ops, portal, credit, ads, hosted pages, and mobile in one workspace, so avoid “global cleanup” edits unless the user asks.
    - Preserve discoverable compatibility code even if it looks redundant; many helpers exist specifically to support partially migrated or legacy data.
    - Never add deterministic portal flows, hard-coded execution branches, or screen-reading style logic unless the user explicitly says the code word: screen read.
    - Before changing any Pura assistant behavior, read ../docs/pura-ai-only-guardrail.md and follow it strictly.
    

    Comments

    More Rules

    View all

    QPrisma Copilot Rules

    A
    alexandergg

    Site Casanova Limaemedeiros Copilot Rules

    V
    victormedeeeiros-design

    Mosl Custom Chart Copilot Rules

    R
    riviangeralt

    InOut App Copilot Rules

    J
    jeanvq

    Fastfood Express Copilot Rules

    J
    jersonjjcr

    Pds Pre View Copilot Rules

    E
    eiriksgata

    Neura weekly digest

    Stay up to date

    The week's most-read AI news, trending AI tools and new automation workflows, in one email. At most once a week. Free, and you can unsubscribe in one click.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for CoPilot and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Games
    • Blog
    • Videos
    • Guides
    • Courses
    • Community
    • Plugins

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this CoPilot resource

    • Extract Internal Links from a Webpagen8n · $9.99 · Related topic
    • Automated Execution Cleanup System with n8n API and Custom Retention Rulesn8n · $9.99 · Related topic
    • Receive and Analyze Emails with Rules in Sublime Securityn8n · $9.99 · Related topic
    • Automate Internal Helpdesk Responses in Slack with AI and Email Escalationn8n · $14.99 · Related topic
    Browse all workflows