Skip to content

docs(cli): remove tables/views scaffold guidance#616

Merged
mk3008 merged 2 commits intomainfrom
codex/601-remove-tables-views-clean
Mar 19, 2026
Merged

docs(cli): remove tables/views scaffold guidance#616
mk3008 merged 2 commits intomainfrom
codex/601-remove-tables-views-clean

Conversation

@mk3008
Copy link
Owner

@mk3008 mk3008 commented Mar 19, 2026

This PR is the clean #601 cut of the tables/views removal work.

It removes the tables/views scaffold guidance, keeps SQL assets under a single obvious location, and updates docs/tests/snapshots to match the new query-unit policy.

It intentionally excludes the unrelated join-direction lint work that was mixed into PR #614.

Summary by CodeRabbit

Release Notes

  • Refactor

    • Simplified repository scaffold structure by removing separate tables/ and views/ directories
    • Enforced a unified query-unit convention: one SQL file per QuerySpec per repository entrypoint per DTO
  • Documentation

    • Updated guidance across all README and policy files to reflect the new query-unit structure
    • Clarified SQL as the single authoritative source for query logic
  • Tests

    • Added validation tests to enforce query-unit guidance across documentation

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

This PR marks a major release for @rawsql-ts/ztd-cli that removes scaffolding support for tables/ and views/ repository folder structures. It consolidates storage rules to enforce 1 SQL file per QuerySpec per repository entrypoint per DTO, updates all related documentation and policies, and removes associated template artifacts and guidance files.

Changes

Cohort / File(s) Summary
Release & Root Documentation
.changeset/quiet-badgers-smile.md, README.md
Marks major version release and adds explicit guidance that queries must align as single units (1 SQL file / 1 QuerySpec / 1 repository entrypoint / 1 DTO) with src/sql/ as the single human-owned source for query logic.
Init Scaffolding Logic
packages/ztd-cli/src/commands/init.ts, packages/ztd-cli/src/utils/agents.ts
Removes scaffolding support for views and tables repository structures by deleting FileKey variants, InitScaffoldLayout fields, and visible AGENTS template targets; updates dry-run file plans accordingly.
Template Root Documentation
packages/ztd-cli/templates/README.md, packages/ztd-cli/templates/README.webapi.md
Restructures template guidance to emphasize query-unit alignment, redefines src/ directory responsibilities (SQL, catalog, repositories), and reinforces 1:1 mapping between SQL files, QuerySpecs, entrypoints, and DTOs.
Query-Unit Focused Policies
packages/ztd-cli/templates/src/catalog/AGENTS.md, packages/ztd-cli/templates/src/infrastructure/persistence/AGENTS.md, packages/ztd-cli/templates/src/infrastructure/persistence/repositories/AGENTS.md, packages/ztd-cli/templates/src/repositories/AGENTS.md
Updates AGENTS guidance to redefine scope granularity from broad categories to individual "query units" and adds REQUIRED constraints enforcing 1:1 alignment across SQL/QuerySpec/entrypoint/DTO artifacts.
Removed Tables/Views Scaffolds
packages/ztd-cli/templates/src/infrastructure/persistence/repositories/{tables,views}/*, packages/ztd-cli/templates/src/repositories/{tables,views}/*
Deletes all AGENTS.md and README.md documentation files from tables and views subdirectories, removing CRUD/read-only policies and repository pattern guidance tied to the removed scaffold structure.
Tests
packages/ztd-cli/tests/directoryFinding.docs.test.ts, packages/ztd-cli/tests/init.command.test.ts
Adds new test file verifying query-unit guidance appears in documentation without tables/views references and that removed directories do not exist; updates init test assertions to expect query-unit text and reflect relocated telemetry import paths and removed scaffold directories.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Hop, hop! The tables and views take flight,
One query shines, crystal-bright,
SQL, QuerySpec, entrypoint, DTO—
Four friends dancing, stealing the show!
Simpler scaffolds mean clearer minds,
What perfect alignment we finally find! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: removal of tables/views scaffold guidance from the CLI documentation and codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/601-remove-tables-views-clean
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@mk3008 mk3008 closed this Mar 19, 2026
@mk3008 mk3008 reopened this Mar 19, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/ztd-cli/tests/directoryFinding.docs.test.ts (1)

31-54: Consider extracting file contents to reduce redundant reads.

The same files are read multiple times (once in the loop at line 39, then again at lines 45, 48, and 51). While this is fine for test clarity and the overhead is negligible, you could cache the reads for cleaner code.

♻️ Optional: Cache file contents
 test('repository guidance centers the single SQL source location', () => {
-  const files = [
-    'packages/ztd-cli/templates/src/repositories/AGENTS.md',
-    'packages/ztd-cli/templates/src/infrastructure/persistence/AGENTS.md',
-    'packages/ztd-cli/templates/src/infrastructure/persistence/repositories/AGENTS.md'
-  ];
-
-  for (const file of files) {
-    const contents = readNormalizedFile(file);
+  const repoAgents = readNormalizedFile('packages/ztd-cli/templates/src/repositories/AGENTS.md');
+  const persistenceAgents = readNormalizedFile('packages/ztd-cli/templates/src/infrastructure/persistence/AGENTS.md');
+  const persistenceRepoAgents = readNormalizedFile('packages/ztd-cli/templates/src/infrastructure/persistence/repositories/AGENTS.md');
+
+  for (const contents of [repoAgents, persistenceAgents, persistenceRepoAgents]) {
     expect(contents).toContain('1 SQL file / 1 QuerySpec / 1 repository entrypoint / 1 DTO');
     expect(contents).toContain('src/sql');
     expect(contents).not.toContain('tables/views');
   }

-  expect(readNormalizedFile('packages/ztd-cli/templates/src/repositories/AGENTS.md')).toContain(
+  expect(repoAgents).toContain(
     'Repositories MUST load SQL assets from `src/sql` through shared loader infrastructure.',
   );
-  expect(readNormalizedFile('packages/ztd-cli/templates/src/infrastructure/persistence/AGENTS.md')).toContain(
+  expect(persistenceAgents).toContain(
     'ZTD-specific workflow rules apply here and in the related `src/sql`, `src/catalog`, and `ztd` assets.',
   );
-  expect(readNormalizedFile('packages/ztd-cli/templates/src/infrastructure/persistence/repositories/AGENTS.md')).toContain(
+  expect(persistenceRepoAgents).toContain(
     'Repositories MUST load SQL assets from `src/sql` through shared loader infrastructure.',
   );
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ztd-cli/tests/directoryFinding.docs.test.ts` around lines 31 - 54,
The test 'repository guidance centers the single SQL source location' reads the
same files multiple times; cache the results by mapping each path in the files
array to its contents once (use the existing files array and readNormalizedFile)
and then assert against the cached contents instead of calling
readNormalizedFile repeatedly for the same paths to reduce redundant reads and
clarify intent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/ztd-cli/tests/directoryFinding.docs.test.ts`:
- Around line 31-54: The test 'repository guidance centers the single SQL source
location' reads the same files multiple times; cache the results by mapping each
path in the files array to its contents once (use the existing files array and
readNormalizedFile) and then assert against the cached contents instead of
calling readNormalizedFile repeatedly for the same paths to reduce redundant
reads and clarify intent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4cd1dea0-c6ef-48a9-9029-6f73397040e0

📥 Commits

Reviewing files that changed from the base of the PR and between b139582 and 4f21f03.

⛔ 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 (20)
  • .changeset/quiet-badgers-smile.md
  • README.md
  • packages/ztd-cli/src/commands/init.ts
  • packages/ztd-cli/src/utils/agents.ts
  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/templates/README.webapi.md
  • packages/ztd-cli/templates/src/catalog/AGENTS.md
  • packages/ztd-cli/templates/src/infrastructure/persistence/AGENTS.md
  • packages/ztd-cli/templates/src/infrastructure/persistence/repositories/AGENTS.md
  • packages/ztd-cli/templates/src/infrastructure/persistence/repositories/tables/AGENTS.md
  • packages/ztd-cli/templates/src/infrastructure/persistence/repositories/tables/README.md
  • packages/ztd-cli/templates/src/infrastructure/persistence/repositories/views/AGENTS.md
  • packages/ztd-cli/templates/src/infrastructure/persistence/repositories/views/README.md
  • packages/ztd-cli/templates/src/repositories/AGENTS.md
  • packages/ztd-cli/templates/src/repositories/tables/AGENTS.md
  • packages/ztd-cli/templates/src/repositories/tables/README.md
  • packages/ztd-cli/templates/src/repositories/views/AGENTS.md
  • packages/ztd-cli/templates/src/repositories/views/README.md
  • packages/ztd-cli/tests/directoryFinding.docs.test.ts
  • packages/ztd-cli/tests/init.command.test.ts
💤 Files with no reviewable changes (10)
  • packages/ztd-cli/templates/src/infrastructure/persistence/repositories/views/AGENTS.md
  • packages/ztd-cli/templates/src/repositories/tables/README.md
  • packages/ztd-cli/templates/src/infrastructure/persistence/repositories/tables/README.md
  • packages/ztd-cli/templates/src/repositories/tables/AGENTS.md
  • packages/ztd-cli/templates/src/infrastructure/persistence/repositories/tables/AGENTS.md
  • packages/ztd-cli/src/utils/agents.ts
  • packages/ztd-cli/templates/src/infrastructure/persistence/repositories/views/README.md
  • packages/ztd-cli/templates/src/repositories/views/AGENTS.md
  • packages/ztd-cli/src/commands/init.ts
  • packages/ztd-cli/templates/src/repositories/views/README.md

@mk3008 mk3008 merged commit ad7b4ea into main Mar 19, 2026
25 checks passed
@mk3008 mk3008 deleted the codex/601-remove-tables-views-clean branch March 19, 2026 04:58
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