{"name":"prd-for-agents","title":"PRD template for AI coding agents","description":"A PRD template written so a coding agent can build from it, with numbered requirements, scope limits, technical notes and checkable acceptance criteria.","category":"specs","updated":"2026-11-08","url":"https://sniptide.com/templates/prd-for-agents","files":[{"name":"docs/specs/csv-export.md","language":"markdown","content":"# CSV export for invoices\n\nStatus: Ready to build\nOwner: Dana (product), Sam (engineering)\nUpdated: 2026-11-08\n\n## Problem\n\nAccountants ask for a spreadsheet of invoices every month. Today support exports it by hand from\nthe database, which takes about 20 minutes per request and arrives a day late.\n\n## Goal\n\nA signed-in user can download their invoices as a CSV file from the Invoices page, filtered the\nsame way as the list on screen.\n\nSuccess: support export requests drop to zero within a month of release.\n\n## Users and stories\n\n- As an owner, I download last month's paid invoices so my accountant can reconcile them.\n- As an accountant with read access, I export invoices for one customer without asking the owner.\n\n## Requirements\n\n1. An **Export CSV** button sits next to the filters on the Invoices page.\n2. The file contains the invoices that match the current filters, in the list's order.\n3. Columns, in this order: number, customer, issue date, due date, status, currency, amount.\n4. Amounts are decimals with two places (19.99), dates are ISO 8601 (2026-11-08).\n5. The file name is `invoices-YYYY-MM-DD.csv`, using the day of the export.\n6. Exports of up to 10,000 rows download straight away. Larger exports show an error that asks\n   the user to narrow the filters.\n7. Users with read access can export. Nobody can export another workspace's invoices.\n\n## Out of scope\n\n- Excel or PDF formats.\n- Scheduled or emailed exports.\n- Exporting line items.\n\n## Technical notes\n\n- Add `GET /api/invoices/export` that takes the same query parameters as `GET /api/invoices`.\n- Reuse `listInvoices` in `lib/invoices.ts` for filtering and permissions. Don't write a second\n  query.\n- Stream the response with `Content-Type: text/csv` and `Content-Disposition: attachment`.\n- Escape fields per RFC 4180: quote fields that contain commas, quotes or line breaks.\n\n## Acceptance criteria\n\n- [ ] With the \"Paid\" and \"October\" filters set, the file holds exactly the invoices on screen.\n- [ ] A customer named `Smith, \"Jr\" Ltd` opens correctly in Excel and Google Sheets.\n- [ ] A user with read access can export; a signed-out request gets 401.\n- [ ] A filter matching 10,001 invoices shows the error and downloads nothing.\n- [ ] Tests cover the CSV escaping and the permission check.\n\n## Open questions\n\n- Should the export include voided invoices when no status filter is set? Current answer: yes,\n  matching the list.\n"}]}