Skip to content

Add template-driven AGENTS guidance - #286

Merged
mk3008 merged 3 commits into
mainfrom
feature/ztd-agent-templates
Dec 10, 2025
Merged

mk3008 merged 3 commits into
mainfrom
feature/ztd-agent-templates

Conversation

@mk3008

@mk3008 mk3008 commented Dec 10, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • factor AGENTS.md guidance into template bundle under packages/ztd-cli/templates so ztd init can reuse it for sql folders
  • add canonical SQL/ddl, enums, and domain-spec AGENTS text and load them from init.ts
  • keep copyAgentsTemplate pointed at the shared template bundle

Testing

  • pnpm test
  • pnpm build
  • pnpm lint

Summary by CodeRabbit

  • Documentation

    • Updated guidance and examples to reflect a per-schema DDL organization and added new AGENTS guidance templates for DDL, enums, and domain specs
  • Refactor

    • Simplified schema output to emit one schema file per namespace in the DDL output and moved AGENTS content to shared templates
  • Tests

    • Adjusted tests to validate the new per-schema output layout and dynamic schema naming

✏️ Tip: You can customize this high-level summary in your review settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Dec 10, 2025 •

Copy link
Copy Markdown

Walkthrough

Restructures DDL layout to per-schema files at sql/ddl/<schema>.sql, switches AGENTS.md generation to template-based loading, and updates CLI commands, templates, docs, and tests to match the new file layout and template locations.

Changes

Cohort / File(s) Summary
DDL layout & docs
packages/drivers/pg-testkit/README.md, packages/ztd-cli/README.md, playgrounds/ztd-playground/README.md, playgrounds/ztd-playground/AGENTS.md, playgrounds/ztd-playground/sql/ddl/AGENTS.md, packages/ztd-cli/AGENTS_ZTD.md
Updated documentation and examples to use per-schema files at sql/ddl/<schema>.sql (e.g., sql/ddl/public.sql) instead of sql/ddl/schemas/*.sql; clarified namespace and seed placement.
CLI init — template-driven AGENTS
packages/ztd-cli/src/commands/init.ts, packages/ztd-cli/src/utils/agents.ts
Refactored AGENTS.md generation to reference a templateName and load shared templates (moved template location to templates/), replacing embedded content with template-based writes; introduced schemaFileName defaulting to configured default schema.
CLI pull — output path change
packages/ztd-cli/src/commands/pull.ts
Removed schemasDir nesting; snapshot files are written directly under outDir as sql/ddl/<schema>.sql (no schemas/ subdirectory) and legacy cleanup remains.
Templates added/updated
packages/ztd-cli/templates/AGENTS_ZTD.md, packages/ztd-cli/templates/sql/ddl/AGENTS.md, packages/ztd-cli/templates/sql/domain-specs/AGENTS.md, packages/ztd-cli/templates/sql/enums/AGENTS.md, packages/ztd-cli/templates/README.md
Added template AGENTS guidance files (AI guardrails, DDL, enums, domain-specs) and updated templates README to reference per-schema DDL files.
Tests adjusted for flat schema output
packages/ztd-cli/tests/cliCommands.test.ts, packages/ztd-cli/tests/init.command.test.ts
Tests updated to assert a single public.sql (or ${defaultSchema}.sql) exists in outDir/sql/ddl/; replaced directory traversal with direct file checks and introduced dynamic schema file naming via DEFAULT_ZTD_CONFIG.ddl.defaultSchema.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas to inspect:
    • packages/ztd-cli/src/commands/init.ts — verify loadTemplate() usage and file-writing semantics for template-backed AGENTS.md.
    • packages/ztd-cli/src/commands/pull.ts — ensure file paths now target outDir correctly and legacy cleanup logic is safe.
    • Tests under packages/ztd-cli/tests/ — confirm assertions and dynamic schema naming match DEFAULT_ZTD_CONFIG.
    • Template locations (packages/ztd-cli/templates/) — ensure templates are packaged and referenced with correct relative paths.

Possibly related PRs

Poem

🐇 I hopped through files with nimble feet,

Moved schemas flat — no nested street.
Templates hummed a tidy song,
AGENTS guided all along,
Per-schema files make my burrow neat. 🌿

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Add template-driven AGENTS guidance' directly reflects the main objective: factoring AGENTS.md guidance into a reusable template bundle for ztd init, and is clear and specific about the primary change.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/ztd-agent-templates

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5f3f90 and 3623230.

📒 Files selected for processing (1)
  • packages/drivers/pg-testkit/README.md (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/drivers/pg-testkit/README.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-and-test (20.x)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
packages/ztd-cli/templates/AGENTS_ZTD.md (1)

9-9: Minor wording nit: “outside of” → “outside” (optional)

Purely stylistic, but you could tighten this sentence to “re‑derive schema metadata outside tests/ztd-row-map.generated.ts” if you want slightly crisper wording; behavior and guidance are already clear either way.

packages/ztd-cli/README.md (1)

43-47: Clarify ddl pull output location vs. layout

The description correctly reflects the “one file per schema under sql/ddl/<schema>.sql” convention and the removal of the schemas/ subdir. You might optionally mention that when --out is used, the same <schema>.sql layout is applied under the chosen directory, not just sql/ddl/.

packages/ztd-cli/templates/sql/ddl/AGENTS.md (1)

1-6: DDL AGENTS template is concise and aligned with ZTD guidance

The template correctly positions sql/ddl as the single source of truth for table structures and directs both humans and AI to this directory. You could optionally call out the per‑schema <schema>.sql pattern explicitly to mirror the README wording, but it’s already serviceable as-is.

packages/ztd-cli/src/commands/init.ts (2)

136-154: AGENTS templates for SQL folders now loaded from shared bundle

Adding templateName to SQL_FOLDER_AGENT_TARGETS and pointing it at sql/ddl/AGENTS.md, sql/enums/AGENTS.md, and sql/domain-specs/AGENTS.md leverages the shared template directory and removes inline markdown duplication. This centralizes guidance nicely.


188-206: Schema file path in init now derived from DEFAULT_ZTD_CONFIG

Using schemaFileName = \${DEFAULT_ZTD_CONFIG.ddl.defaultSchema}.sql`and wiringabsolutePaths.schematoDEFAULT_ZTD_CONFIG.ddlDirensures init writes/pulls into the same.sqlfile the rest of the tooling expects. As a future enhancement, you might consider reading an existingztd.config.json(if present) to respect customddlDir/defaultSchemaon re‑runs ofztd init`, but the current behavior is correct for first‑run scaffolding.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4f843c and c5f3f90.

⛔ Files ignored due to path filters (1)
  • packages/ztd-cli/tests/__snapshots__/init.command.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (16)
  • packages/drivers/pg-testkit/README.md (1 hunks)
  • packages/ztd-cli/AGENTS_ZTD.md (1 hunks)
  • packages/ztd-cli/README.md (3 hunks)
  • packages/ztd-cli/src/commands/init.ts (3 hunks)
  • packages/ztd-cli/src/commands/pull.ts (1 hunks)
  • packages/ztd-cli/src/utils/agents.ts (1 hunks)
  • packages/ztd-cli/templates/AGENTS_ZTD.md (1 hunks)
  • packages/ztd-cli/templates/README.md (1 hunks)
  • packages/ztd-cli/templates/sql/ddl/AGENTS.md (1 hunks)
  • packages/ztd-cli/templates/sql/domain-specs/AGENTS.md (1 hunks)
  • packages/ztd-cli/templates/sql/enums/AGENTS.md (1 hunks)
  • packages/ztd-cli/tests/cliCommands.test.ts (2 hunks)
  • packages/ztd-cli/tests/init.command.test.ts (4 hunks)
  • playgrounds/ztd-playground/AGENTS.md (1 hunks)
  • playgrounds/ztd-playground/README.md (3 hunks)
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Remove console debugging before committing.

Files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/src/utils/agents.ts
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/src/**/*.{ts,tsx}: All exported classes, functions, and types in src/ are considered part of the public API and must have clear English JSDoc attached to their declaration.
When adding a new exported symbol in src/ (class, function, type, interface, enum, etc.), always add English JSDoc in the same commit that briefly explains the role of the API and how to consume it.
When modifying an exported symbol, update the existing docstring to keep it truthful and never delete a docstring merely to keep the diff small.
If a helper is not meant to be public, make it non-exported or add @internal to its docstring rather than leaving an undocumented export.

Files:

  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/src/utils/agents.ts
  • packages/ztd-cli/src/commands/init.ts
🧠 Learnings (51)
📓 Common learnings
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:40.447Z
Learning: Applies to playgrounds/ztd-playground/sql/ddl/sql/ddl/schemas/*.sql : Store table structure definitions (CREATE TABLE, ALTER TABLE, indexes, constraints) in `sql/ddl/schemas/*.sql`
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:40.447Z
Learning: Applies to playgrounds/ztd-playground/sql/ddl/sql/ddl/schemas/**/*.sql : Treat SQL files in `sql/ddl/schemas/` as the single source of truth for database schemas
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Treat `tests/ztd-row-map.generated.ts` and `sql/ddl/` (or legacy `ddl/`) directory as canonical schema and row map; load fixtures from them rather than reverse-engineering the database structure
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Applies to playgrounds/ztd-playground/sql/**/*.sql : Keep every table definition inside `sql/ddl/schemas/*.sql`, enums under `sql/enums/*.sql`, and executable specs inside `sql/domain-specs/*.sql`.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:40.447Z
Learning: Reference the `sql/ddl/schemas/` directory when modifying or understanding table structures
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/sql/ddl/**/*.sql : Use DDL files only for canonical schema information and true shared baseline data; do not put per-test seeds inside schema files in pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Parse DDL files once per client/pool instance in pg-testkit to produce fixture schema and baseline fixture rows deterministically
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Only include DDL files, minimal SQL examples in `src/`, and ZTD-focused tests under `tests/` in the playground. Avoid adding application logic, persistence layers, or business services.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Load DDL-based fixtures using DDLToFixtureConverter when projects contain `tests/ztd-row-map.generated.ts` and `sql/ddl/` directory
📚 Learning: 2025-12-09T12:47:40.447Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:40.447Z
Learning: Applies to playgrounds/ztd-playground/sql/ddl/sql/ddl/schemas/**/*.sql : Treat SQL files in `sql/ddl/schemas/` as the single source of truth for database schemas

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • playgrounds/ztd-playground/README.md
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:40.447Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:40.447Z
Learning: Applies to playgrounds/ztd-playground/sql/ddl/sql/ddl/schemas/*.sql : Store table structure definitions (CREATE TABLE, ALTER TABLE, indexes, constraints) in `sql/ddl/schemas/*.sql`

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • packages/ztd-cli/templates/sql/enums/AGENTS.md
  • playgrounds/ztd-playground/README.md
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md
  • packages/ztd-cli/templates/sql/domain-specs/AGENTS.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-08T14:13:45.120Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.120Z
Learning: Applies to ztd.config.json : Update `ztd.config.json` whenever you change the target schema or search path so the rewrite pipeline still matches tables as expected.

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/src/utils/agents.ts
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/src/commands/init.ts
  • playgrounds/ztd-playground/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/sql/ddl/**/*.sql : Use DDL files only for canonical schema information and true shared baseline data; do not put per-test seeds inside schema files in pg-testkit

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md
  • packages/drivers/pg-testkit/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:35.496Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Applies to playgrounds/ztd-playground/sql/**/*.sql : Keep every table definition inside `sql/ddl/schemas/*.sql`, enums under `sql/enums/*.sql`, and executable specs inside `sql/domain-specs/*.sql`.

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/src/commands/init.ts
  • packages/ztd-cli/templates/sql/enums/AGENTS.md
  • playgrounds/ztd-playground/README.md
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md
  • packages/ztd-cli/templates/sql/domain-specs/AGENTS.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Load DDL-based fixtures using DDLToFixtureConverter when projects contain `tests/ztd-row-map.generated.ts` and `sql/ddl/` directory

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/templates/AGENTS_ZTD.md
  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • playgrounds/ztd-playground/README.md
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md
  • packages/drivers/pg-testkit/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Treat `tests/ztd-row-map.generated.ts` and `sql/ddl/` (or legacy `ddl/`) directory as canonical schema and row map; load fixtures from them rather than reverse-engineering the database structure

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • playgrounds/ztd-playground/README.md
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md
  • packages/drivers/pg-testkit/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Parse DDL files once per client/pool instance in pg-testkit to produce fixture schema and baseline fixture rows deterministically

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/templates/AGENTS_ZTD.md
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • playgrounds/ztd-playground/README.md
  • packages/drivers/pg-testkit/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:40.447Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:40.447Z
Learning: Reference the `sql/ddl/schemas/` directory when modifying or understanding table structures

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • playgrounds/ztd-playground/AGENTS.md
  • playgrounds/ztd-playground/README.md
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Do not reconstruct DDL or row-type definitions inside pg-testkit when the project already ships `tests/ztd-row-map.generated.ts`; rely on the generated TestRowMap instead

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/templates/AGENTS_ZTD.md
  • packages/ztd-cli/src/utils/agents.ts
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • packages/drivers/pg-testkit/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Provide test-specific rows via `tableRows` or `withFixtures()` rather than in DDL schema files when using pg-testkit

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/templates/AGENTS_ZTD.md
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • packages/drivers/pg-testkit/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:35.496Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.test.ts : Always wire Postgres execution through `tests/testkit-client.ts`, which opens a `pg.Client`, passes it into `rawsql-ts/pg-testkit`, and shares the connection across tests. Regenerate the helper with `pnpm playground:gen-config` if you need to move SQL directories or change connection defaults.

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/templates/AGENTS_ZTD.md
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/tests/init.command.test.ts
  • playgrounds/ztd-playground/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:35.496Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.test.ts : Import `ZtdConfig`, `ZtdRowShapes`, `ZtdTableName`, and `tableFixture()` from `tests/ztd-row-map.generated.ts` instead of duplicating row interfaces inside tests.

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/templates/AGENTS_ZTD.md
  • packages/ztd-cli/src/utils/agents.ts
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • playgrounds/ztd-playground/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Maintain fixture precedence order in pg-testkit: DDL fixtures (schema + shared seed rows) → Manual fixtures (`tableDefinitions`, `tableRows`) → Scoped fixtures (`client.withFixtures()`), where later layers override earlier ones

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/drivers/pg-testkit/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:35.496Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.test.ts : Never issue DDL statements against Postgres from the playground. All CRUD operations must flow through pg-testkit so they resolve to fixture-backed `SELECT` queries.

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/templates/AGENTS_ZTD.md
  • playgrounds/ztd-playground/AGENTS.md
  • playgrounds/ztd-playground/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Rewrite all CRUD statements (INSERT, UPDATE, DELETE) to fixture-backed SELECT queries before execution in pg-testkit

Applied to files:

  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/templates/AGENTS_ZTD.md
  • playgrounds/ztd-playground/README.md
  • packages/drivers/pg-testkit/README.md
📚 Learning: 2025-12-02T22:58:15.329Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.329Z
Learning: Applies to packages/testkit-core/tests/**/*.{test,spec}.{ts,tsx} : Add test coverage for fixture resolution paths, CRUD rewrite transformations, CTE + multi-statement handling, fallback logic, identifier casing rules, and error diagnostics in testkit-core

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/tests/init.command.test.ts
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Adapt `testkit-core` rewrite results to PostgreSQL in pg-testkit implementation

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/templates/AGENTS_ZTD.md
  • packages/drivers/pg-testkit/README.md
📚 Learning: 2025-12-02T22:58:15.329Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.329Z
Learning: Applies to packages/testkit-core/src/**/*.{ts,tsx} : warn and passthrough modes in testkit-core must behave predictably and never silently rewrite incorrect SQL

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/tests/init.command.test.ts
📚 Learning: 2025-12-02T22:57:55.626Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.626Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx,js} : No stray console.log or temp files outside ./tmp/ directory

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:35.496Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Applies to playgrounds/ztd-playground/tests/ztd-layout.generated.ts : Do not hand-edit `tests/ztd-layout.generated.ts`; regenerate it with `pnpm playground:gen-config` (or `pnpm --filter ztd-playground exec ztd ztd-config`) so the CLI and tests stay aligned.

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/templates/AGENTS_ZTD.md
  • packages/ztd-cli/src/utils/agents.ts
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • playgrounds/ztd-playground/README.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Support full parallel test execution in pg-testkit with no shared state

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Execute rewritten SELECT queries against a live pg client/pool in pg-testkit

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • playgrounds/ztd-playground/README.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Use `createPgTestkitClient` to lazily open a pg connection and ensure every `.query` call goes through rewrite + fixture application

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Normalize `$1`, `$2`, ... placeholders before rewrite and restore them before execution in pg-testkit

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/utils/agents.ts
📚 Learning: 2025-12-02T22:57:55.626Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.626Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.test.{ts,tsx} : Use Vitest for both unit and integration-level coverage; integration tests should exercise real better-sqlite3 connections

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/tests/init.command.test.ts
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Preserve full API surface (`.query`, `.connect`, `.release`) when wrapping an existing client or pool with `wrapPgClient`

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Do not introduce rewrite logic inside pg-testkit; rewrite logic belongs exclusively in testkit-core

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
📚 Learning: 2025-12-08T14:13:45.120Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.120Z
Learning: Validation checklist: Run `pnpm lint`, `pnpm test` or `pnpm --filter <pkg> test`, `pnpm build`, and run benchmarks for SQL-rewriter changes when relevant.

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/tests/init.command.test.ts
  • playgrounds/ztd-playground/README.md
📚 Learning: 2025-12-08T14:13:45.120Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.120Z
Learning: Ensure `packages/core/dist` outputs stay synchronized with the pnpm store copy that CLI tests consume. Run `pnpm --filter rawsql-ts build` which executes `scripts/sync-rawsql-dist.js` as a `postbuild` step.

Applied to files:

  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/src/commands/pull.ts
  • packages/ztd-cli/tests/init.command.test.ts
📚 Learning: 2025-12-02T22:57:55.626Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.626Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx} : Do not add physical table management (CREATE TABLE, ALTER TABLE, migrations) through the wrapped driver

Applied to files:

  • packages/ztd-cli/src/commands/pull.ts
📚 Learning: 2025-12-02T22:58:15.329Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.329Z
Learning: Applies to packages/testkit-core/src/**/*.{ts,tsx} : In rawsql-ts/testkit-core, remain DBMS-agnostic with no Postgres/SQLite conditionals or behavior

Applied to files:

  • packages/ztd-cli/templates/AGENTS_ZTD.md
📚 Learning: 2025-12-08T14:13:45.120Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.120Z
Learning: Applies to packages/pg-testkit/src/**/*.{ts,tsx} : Application SQL may freely use normal CRUD (`INSERT`, `UPDATE`, `DELETE`). pg-testkit will automatically rewrite them into `SELECT` queries. Library code must never bypass the rewriter.

Applied to files:

  • packages/ztd-cli/templates/AGENTS_ZTD.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Never create or mutate real tables in pg-testkit; prohibit `CREATE TABLE`, `ALTER TABLE`, and migrations

Applied to files:

  • packages/ztd-cli/templates/AGENTS_ZTD.md
📚 Learning: 2025-12-08T14:13:45.120Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.120Z
Learning: Applies to {packages/core,packages/testkit-core,packages/pg-testkit,packages/sqlite-testkit}/src/**/*.{ts,tsx} : All SQL rewrites must rely on `rawsql-ts` AST utilities (parser, analyzer, splitQueries). Regex-based rewrites are allowed only as guarded fallbacks with comments explaining why. Block contributions introducing regex parsing when an AST alternative exists.

Applied to files:

  • packages/ztd-cli/templates/AGENTS_ZTD.md
📚 Learning: 2025-12-08T14:13:45.120Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.120Z
Learning: Document any deviations from the standard formatting workflow in AGENTS so AI contributors understand that formatting is owned by the scripts, not by hand edits.

Applied to files:

  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • packages/ztd-cli/AGENTS_ZTD.md
  • packages/ztd-cli/templates/sql/enums/AGENTS.md
  • packages/ztd-cli/templates/sql/domain-specs/AGENTS.md
📚 Learning: 2025-12-09T12:47:35.496Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Only include DDL files, minimal SQL examples in `src/`, and ZTD-focused tests under `tests/` in the playground. Avoid adding application logic, persistence layers, or business services.

Applied to files:

  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/src/commands/init.ts
  • playgrounds/ztd-playground/README.md
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md
  • packages/ztd-cli/templates/sql/domain-specs/AGENTS.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:43.255Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/domain-specs/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:43.255Z
Learning: Applies to playgrounds/ztd-playground/sql/domain-specs/sql/domain-specs/** : Store SQL SELECT specifications that describe domain behaviors under `sql/domain-specs/`. Each file must contain a complete executable SELECT statement.

Applied to files:

  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/src/commands/init.ts
  • packages/ztd-cli/templates/sql/enums/AGENTS.md
  • playgrounds/ztd-playground/README.md
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md
  • packages/ztd-cli/templates/sql/domain-specs/AGENTS.md
📚 Learning: 2025-12-08T14:13:45.120Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.120Z
Learning: Applies to ztd.config.json : Application SQL can omit schema qualifiers (e.g., `SELECT ... FROM users`). pg-testkit maps those references to canonical `schema.table` keys by consulting the `ddl.defaultSchema` / `ddl.searchPath` block in `ztd.config.json` before looking up fixtures or DDL metadata.

Applied to files:

  • packages/ztd-cli/templates/sql/ddl/AGENTS.md
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • playgrounds/ztd-playground/README.md
  • playgrounds/ztd-playground/sql/ddl/AGENTS.md
  • packages/drivers/pg-testkit/README.md
  • packages/ztd-cli/README.md
📚 Learning: 2025-12-02T22:57:21.011Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.011Z
Learning: Applies to packages/core/src/**/*.ts : Refactor for clarity and document public APIs before running the validation pipeline

Applied to files:

  • packages/ztd-cli/src/utils/agents.ts
📚 Learning: 2025-12-09T12:47:35.496Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.test.ts : Provide explicit fixtures for each test using `tableFixture('schema.table', [{ ... }])`. Do not reuse shared mutable data between tests.

Applied to files:

  • playgrounds/ztd-playground/AGENTS.md
  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
  • playgrounds/ztd-playground/README.md
📚 Learning: 2025-12-02T22:57:55.626Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.626Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.test.{ts,tsx} : Ensure tests remain deterministic regardless of file-backed vs. memory-backed SQLite configurations

Applied to files:

  • packages/ztd-cli/tests/init.command.test.ts
  • packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Ensure all added features have tests in `tests/` directory when contributing to pg-testkit

Applied to files:

  • packages/ztd-cli/tests/init.command.test.ts
📚 Learning: 2025-12-09T12:47:35.496Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Use `pnpm format` to normalize TypeScript, SQL, Markdown, and config files; do not hand-edit whitespace or indentation.

Applied to files:

  • packages/ztd-cli/tests/init.command.test.ts
📚 Learning: 2025-12-08T14:13:45.120Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.120Z
Learning: Applies to {packages/pg-testkit,packages/sqlite-testkit}/**/*.test.{ts,tsx} : Do not treat the backing DB as a migration target. The DB engine is only for planning/type-checking. Never execute `CREATE TABLE`, `ALTER TABLE`, or seed `INSERT`s over a pg-testkit connection.

Applied to files:

  • packages/ztd-cli/tests/init.command.test.ts
  • packages/drivers/pg-testkit/README.md
📚 Learning: 2025-12-02T22:57:55.626Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.626Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx,js} : All SQL must flow through the testkit-core AST rewriter before execution; new rewrite behavior must be added to testkit-core first, then threaded into sqlite-testkit

Applied to files:

  • packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:45.696Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/enums/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:45.696Z
Learning: Applies to playgrounds/ztd-playground/sql/enums/**/*.sql : Declare ENUM-like domain values using simple SQL `VALUES` syntax so fixtures and rewrites stay consistent, avoiding magic numbers

Applied to files:

  • packages/ztd-cli/templates/sql/enums/AGENTS.md
  • packages/ztd-cli/templates/sql/domain-specs/AGENTS.md
📚 Learning: 2025-12-09T12:47:35.496Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:35.496Z
Learning: Set `DATABASE_URL` environment variable before running `pnpm playground:test` or any spec that touches the testkit helper; the helper throws a clear error when it is missing.

Applied to files:

  • playgrounds/ztd-playground/README.md
📚 Learning: 2025-12-09T12:47:23.688Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.688Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Implement `.withFixtures()` overlay on pg-testkit clients to apply scenario-specific rows while maintaining fixture precedence

Applied to files:

  • packages/drivers/pg-testkit/README.md
📚 Learning: 2025-12-02T22:57:55.626Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.626Z
Learning: Applies to packages/drivers/sqlite-testkit/**/README.md : Adapters must be documented in README.md with realistic fixture-based examples

Applied to files:

  • packages/drivers/pg-testkit/README.md
🧬 Code graph analysis (1)
packages/ztd-cli/src/commands/init.ts (1)
packages/ztd-cli/src/utils/ztdProjectConfig.ts (1)
  • DEFAULT_ZTD_CONFIG (31-36)
🪛 LanguageTool
packages/ztd-cli/templates/AGENTS_ZTD.md

[style] ~9-~9: This phrase is redundant. Consider using “outside”.
Context: ...efinitions or re-derive schema metadata outside of tests/ztd-row-map.generated.ts. If a ...

(OUTSIDE_OF)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-and-test (20.x)
🔇 Additional comments (20)
packages/ztd-cli/templates/README.md (1)

12-12: Aligns workflow step with per‑schema DDL layout

Updating the workflow to sql/ddl/<schema>.sql matches the new per‑schema DDL convention; no issues from a tooling or docs standpoint.

packages/ztd-cli/AGENTS_ZTD.md (1)

1-3: Clarifies mirror relationship to shared template bundle

Stating that this file mirrors templates/AGENTS_ZTD.md makes the duplication explicit and should help keep CLI guidance and the bundled template in sync; no further changes needed here.

packages/ztd-cli/src/utils/agents.ts (1)

9-10: Template resolution now targets shared templates/ bundle

Pointing templatePath at ../../templates/AGENTS_ZTD.md matches the new template bundle location, and the function still avoids overwriting existing AGENTS files, so behavior remains safe.

playgrounds/ztd-playground/AGENTS.md (1)

11-11: Playground schema guidance aligned with per‑schema DDL files

Updating the bullet to sql/ddl/<schema>.sql keeps the playground’s instructions consistent with the new per‑schema layout and the shared templates; looks good.

packages/ztd-cli/templates/sql/enums/AGENTS.md (1)

1-13: Enum template clearly encodes VALUES‑based enums and discourages magic numbers

The example and guidance to use simple VALUES definitions and avoid magic numbers align with the existing playground enums guidance; this is a solid template addition.

Based on learnings, this matches the prior recommendation to keep ENUM‑like values in sql/enums/*.sql using VALUES.

packages/ztd-cli/templates/sql/domain-specs/AGENTS.md (1)

1-18: Domain-specs template reinforces SELECT‑only, executable specs

Requiring each domain-spec file to be a full executable SELECT and documenting it with a realistic example matches the existing domain-spec AGENTS guidance and will help keep these specs consistent.

Based on learnings, this lines up with the prior rule that sql/domain-specs/*.sql must be complete SELECT statements describing domain behaviors.

playgrounds/ztd-playground/sql/ddl/AGENTS.md (1)

3-3: No action needed—DDL path documentation is already current

The file correctly documents the new sql/ddl/<schema>.sql convention. No stale sql/ddl/schemas/ references remain in the codebase, so no cleanup is required.

packages/ztd-cli/README.md (2)

25-35: ztd init schema bullet matches new per‑schema layout

The sql/ddl/<schema>.sql wording with public.sql as the default is consistent with the new runPullSchema behavior and the updated tests; this keeps init docs aligned with actual output.


105-111: AI Coding Workflow step now points at the right schema files

Step 1’s reference to sql/ddl/<schema>.sql (e.g., public.sql) matches the new DDL organization and the generated layout file, so the workflow guidance remains accurate.

packages/ztd-cli/src/commands/pull.ts (1)

54-71: Schema snapshots now correctly flatten to <outDir>/<schema>.sql

Writing each schema directly under outDir using sanitizeSchemaFileName(schema) while cleaning up the legacy schema.sql and schemas/ directory aligns the implementation with the updated tests and docs. Behavior is backwards‑compatible in that it removes old layouts only if present.

packages/ztd-cli/tests/init.command.test.ts (3)

5-20: Tests now derive schema filename from DEFAULT_ZTD_CONFIG

Using DEFAULT_ZTD_CONFIG.ddl.defaultSchema to compute schemaFileName and schemaFilePath() keeps tests automatically aligned if the default schema changes, and matches how runInitCommand now chooses the initial DDL file.


63-81: Manual‑DDL init test matches new <schema>.sql seed behavior

Asserting existence and contents of schemaFilePath(workspace) is consistent with the new sql/ddl/<schema>.sql layout and the SAMPLE_SCHEMA content; the rest of the expectations are unchanged and still valid.


84-120: DB‑first init test stubs pull into the right file

The runPullSchema stub writing schemaFileName under options.out mirrors the real runPullSchema behavior (writing <schema>.sql into the DDL dir), and the subsequent read through schemaFilePath(workspace) verifies the correct content. This keeps the wizard test tightly coupled to the new layout.

packages/ztd-cli/tests/cliCommands.test.ts (2)

2-25: Expanded fs imports are appropriate for temp directory helpers

Adding mkdirSync, mkdtempSync, readFileSync, and writeFileSync to the fs import reflects actual usage in this file and avoids relying on implicit globals; no issues here.


127-142: pull CLI test correctly targets public.sql and asserts no schemas/ dir

The test now looks for outDir/public.sql, verifies the schemas subdirectory is absent, and still checks that the legacy schema.sql is not created. This precisely matches the updated runPullSchema behavior and guards against regressions in layout.

playgrounds/ztd-playground/README.md (3)

11-17: Quick loop step now points at per‑schema DDL files

Referencing sql/ddl/<schema>.sql (e.g., ecommerce.sql) in the loop matches the new layout and makes it clearer where to edit schemas in the playground.


24-28: SQL layout bullet accurately describes flattened DDL organization

Describing sql/ddl/ as holding all table DDL with “each namespace lives in sql/ddl/<schema>.sql” is consistent with the rest of the PR and keeps the playground instructions in sync with the CLI behavior.


37-38: EC schema reference updated to the new ecommerce.sql location

Pointing to sql/ddl/ecommerce.sql for the sample domain is correct under the per‑schema layout and matches how schemas are now organized.

packages/ztd-cli/src/commands/init.ts (2)

156-161: NEXT_STEPS messaging reflects new per‑schema DDL layout

Updating step 1 to “Review the schema files under sql/ddl/.sql” keeps the post‑init summary consistent with the new schema organization and the README/docs.


625-647: ensureSqlFolderAgents now emits canonical AGENTS content from templates

Loading templateContents = loadTemplate(target.templateName) and writing it only when no AGENTS file exists preserves project‑specific overrides while ensuring new projects all start from the same bundled guidance. The eager ensureDirectory call before checking fileExists is harmless and guarantees folder creation even when users pre‑seed AGENTS files.

Comment thread packages/drivers/pg-testkit/README.md
@mk3008
mk3008 merged commit 5222a6b into main Dec 10, 2025
13 checks passed
@mk3008
mk3008 deleted the feature/ztd-agent-templates branch December 10, 2025 22:55
@coderabbitai coderabbitai Bot mentioned this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant