Skip to content

feat: Publish the codemods as @data-client/codemods - #4409

Merged
ntucker merged 7 commits into
masterfrom
claude/data-client-codemods
Oct 19, 2026
Merged

ntucker merged 7 commits into
masterfrom
claude/data-client-codemods

Conversation

@ntucker

@ntucker ntucker commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Nathaniel · project thread

Motivation

Migration codemods are fetched from dataclient.io at run time, so they aren't versioned with releases, and the only way for a skill to run one offline is to ship the script itself. Package security reviewers flag scripts inside packages. A dedicated codemods package lets skills just name a command.

Before:

npx jscodeshift -t https://dataclient.io/codemods/v0.18.js --extensions=ts,tsx,js,jsx src/

After:

npx @data-client/codemods v0.18 src/

Solution

  • New @data-client/codemods package (CommonJS, no build) with a data-client-codemods bin. It validates the codemod name, lists the available ones, skips node_modules, and passes every other jscodeshift option (--dry, --print, --extensions) through to jscodeshift's own CLI.
  • The four transforms (v0.15, v0.16, v0.18, axios-to-rest) move from website/static/codemods/ to packages/codemods/src/transforms/. The old dataclient.io URLs keep working through symlinks, since released blog posts and docs link them.
  • Their tests now run in jest's Node project. They never ran before, and three were stale: v0.15 returned undefined on files it didn't change, which fails defineInlineTest (it now returns the source, like v0.18), and two axios-to-rest expectations didn't match its current output (source order and blank lines). A CLI test covers the usage error and a real run that skips node_modules.
  • jscodeshift moves from the root devDependencies to the package's dependencies.
  • Changeset: minor for the first release (0.0.0 to 0.1.0), with a no-agent-impact reason since nothing existing changes.

Open questions

  • Docs, blog posts and skills still show the URL command. I'll switch them to npx @data-client/codemods in a follow-up once the package is on npm, so the docs never point at a package that isn't published yet.
  • #4407 already removes the axios codemod copy that the REST setup skill bundled.

Generated by Claude Code


Note

Low Risk
New dev-time migration package; runtime library behavior is unchanged, with backward-compatible website symlinks for old codemod URLs.

Overview
Introduces @data-client/codemods, a versioned npm package so migrations run as npx @data-client/codemods <codemod> <path> instead of fetching scripts from dataclient.io. A small CLI (data-client-codemods) discovers transforms under packages/codemods/src/transforms/, validates the codemod name, sets --ignore-pattern=node_modules, and forwards other jscodeshift flags (--dry, --print, etc.).

The four transforms (v0.15, v0.16, v0.18, axios-to-rest) move from website/static/codemods/ into the package; symlinks at the old website paths keep existing dataclient.io URLs working. jscodeshift moves from the repo root into the package dependency.

Tests and tooling: Jest Node project covers transform inline tests plus a CLI integration test; codemods are excluded from coverage floors. ESLint treats packages/codemods/**/*.js as CommonJS/Node. scripts/check-dts-parse.mjs skips packages with no types field. The v0.18 migration skill’s codemod source link points at the new package path.

Reviewed by Cursor Bugbot for commit b52358b. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b52358b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@data-client/codemods Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-19T18:40:38.684643Z b52358b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 112 kB

ℹ️ View Unchanged
Filename Size
examples/test-bundlesize/dist/App.js 1.45 kB
examples/test-bundlesize/dist/polyfill.js 301 B
examples/test-bundlesize/dist/rdcClient.js 10.8 kB
examples/test-bundlesize/dist/rdcEndpoint.js 8.04 kB
examples/test-bundlesize/dist/rdcNextjs.js 12.4 kB
examples/test-bundlesize/dist/rdcPipeableStream.js 9.65 kB
examples/test-bundlesize/dist/react.js 68.6 kB
examples/test-bundlesize/dist/webpack-runtime.js 698 B

compressed-size-action

ntucker commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator Author

Staff engineer (Cursor agent): LGTM at f7d5b56. No change requested for this PR.

Architecture: a thin wrapper that hands argv to jscodeshift's own CLI is the simplest shape here. It keeps every jscodeshift option without re-implementing them, the codemod list comes from the transforms/ folder so there's no second list to drift, and one long-lived package (rather than one per release) is the right place for v0.19+ codemods. I didn't find an existing util or library this duplicates; jscodeshift is already the proven dependency.

What I actually checked

  • Moved transforms vs. the deleted website/static/codemods/*.js: I diffed them line by line from the PR diff. The only changes are the usage header comments, v0.15 returning fileInfo.source instead of undefined, v0.15 swapping try { push } catch for an if guard (same behavior, since a missing j.X is just undefined), and a commented empty catch in v0.16.
  • File types: jscodeshift 17.4.0's bin/jscodeshift.js (read from unpkg) defaults --extensions to Babel's defaults plus ts,tsx, so the CLI covers TypeScript without passing --extensions, as the README says. jscodeshift 17 has no exports field, so the deep require('jscodeshift/bin/jscodeshift.js') resolves, and cli.node.js would catch it if that changes.
  • Nothing outside docs, blog posts and skills uses jscodeshift (GitHub code search), so dropping it from root devDependencies is safe.
  • The root dataclient.io URLs are unaffected: versionCurrent.json serves the root from 0.18.x, and website-port.yml skips commits that touch more than website/(src|static), so this commit won't port symlinks into packages/codemods that don't exist on that branch. On master (/next/), the symlinks are relative and resolve.
  • Merge order with feat: Ship agent skills inside the npm packages #4407 works either way. regenerate.yml already watches packages/**, so transform edits still trigger the skill regeneration until feat: Ship agent skills inside the npm packages #4407 removes the bundled copy, and the rest-setup skill's copy resolves through the new symlink.

Only read or inferred, not run: I didn't run jest or the CLI. Unit tests, lint, website (Docusaurus copying the symlinked static files) and Bugbot were still pending when I reviewed.

Non-blocking note: the transform headers already say npx @data-client/codemods ..., while the docs wait for the publish. That's fine, since the headers only show on /next/ until the release. When you do the docs follow-up, keep the website/static/codemods symlinks, because released blog posts link those URLs.

@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.37%. Comparing base (b1d40fd) to head (b52358b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4409   +/-   ##
=======================================
  Coverage   98.37%   98.37%           
=======================================
  Files         161      161           
  Lines        3072     3072           
  Branches      604      604           
=======================================
  Hits         3022     3022           
  Misses         10       10           
  Partials       40       40           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview: https://docs-site-pr-4409-data-client.vercel.app

Built from b52358b merged into master (this build).

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

`--transform=${path.join(dir, `${codemod}.js`)}`,
'--ignore-pattern=node_modules',

P1 Badge Include TypeScript in the default extension list

When users run the documented command npx @data-client/codemods v0.18 src/, this forwards no --extensions option, and jscodeshift's --extensions=EXT option defaults to js. Consequently, conventional .ts and .tsx sources are silently skipped even though the README says TypeScript is processed and the CLI test expects a .ts file to change; add a default such as --extensions=js,jsx,ts,tsx while still allowing callers to override it.


* npx @data-client/codemods axios-to-rest src/

P1 Badge Regenerate the bundled axios transform

Changing this source also changes the symlinked .agents/skills/data-client-rest-setup/scripts/axios-to-rest.js, but the regular generated copy at .agents/skills/data-client-setup/references/data-client-rest-setup/scripts/axios-to-rest.js still contains the old npx jscodeshift usage. The regenerate workflow reruns yarn build:skills and fails when generated references become dirty, so run the generator and commit its updated output.

AGENTS.md reference: AGENTS.md:L46-L47


../../../packages/codemods/src/transforms/v0.18.js

P1 Badge Keep website codemod assets valid after nesting the build

These relative links resolve while located at website/build/codemods, but the checked site-preview.yml flow moves that directory to website/build/next/codemods at lines 150–154. From the nested location, ../../../packages/... resolves under website/packages, which does not exist, so builds served from /next contain dangling codemod assets instead of the JavaScript previously copied there; use copied files or links whose targets remain valid after this relocation.


'--ignore-pattern=node_modules',

P2 Badge Ignore nested node_modules directories

The --ignore-pattern option is a glob, so the bare node_modules pattern does not cover paths such as packages/app/node_modules/dep/file.js. When a user runs the CLI over . or a monorepo directory, those installed sources can therefore enter the traversal and be rewritten; pass a recursive pattern such as **/node_modules/** and extend the test to include a nested dependency.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

ntucker commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator Author

Re the Codex review of f7d5b56:

  1. Default extensions (P1). No change needed. The README's js default is out of date. jscodeshift 17.4's bin/jscodeshift.js defaults --extensions to Babel's DEFAULT_EXTENSIONS plus ts,tsx. The CLI test (cli.node.js) passes no --extensions and asserts that src/schema.ts gets rewritten, and it passes.
  2. Regenerate the bundled axios copy (P1). Fixed in 40ba8da (yarn build:skills output committed).
  3. /next relocation (P1). No change needed. Docusaurus copies static/ through the bundler's copy plugin, which reads each file and emits its contents as an asset. So website/build/codemods/*.js are regular files, not symlinks, and moving them under next/ can't leave them dangling. I verified this by running CopyRspackPlugin over website/static/codemods: the output holds four regular files with the transform source.
  4. Nested node_modules (P2). No change needed. jscodeshift's addIgnorePattern expands a pattern with no slash to **/node_modules. f477f9f adds a packages/app/node_modules/dep/schema.ts case to the CLI test, which confirms it stays untouched.

Generated by Claude Code

@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.

npx @data-client/codemods <codemod> <path> runs a migration codemod from npm,
so skills can reference a versioned command instead of shipping scripts.
The transforms move to packages/codemods, and dataclient.io/codemods/*.js
stays available through symlinks. Their tests now run in jest (they never
ran before), with three stale expectations fixed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AVZVL3iq5Cc9b6W2Q3V7G
check-dts-parse skips packages that publish no declarations, coverage
thresholds leave out the dev-time codemods like other tooling, and the
skill bundling the axios codemod picks up its new usage comment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AVZVL3iq5Cc9b6W2Q3V7G
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AVZVL3iq5Cc9b6W2Q3V7G
… return the source

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AVZVL3iq5Cc9b6W2Q3V7G
…sion-bodied arrow schema methods

Under the tsx parser these were skipped or, for an arrow with an expression
body, got new params while the body kept calling the removed unvisit/visit.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AVZVL3iq5Cc9b6W2Q3V7G
…forms

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AVZVL3iq5Cc9b6W2Q3V7G
@ntucker
ntucker force-pushed the claude/data-client-codemods branch from 69708f9 to 9eb91cc Compare October 19, 2026 18:37
@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.

…s before parsing

The transforms always parse with tsx, so ESTree and Flow node types never
appear. v0.16, v0.18 and axios-to-rest return early when the source can't
contain the import they need.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AVZVL3iq5Cc9b6W2Q3V7G
@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.

@ntucker
ntucker added this pull request to the merge queue Oct 19, 2026
Merged via the queue into master with commit 7d1c42a Oct 19, 2026
43 of 44 checks passed
@ntucker
ntucker deleted the claude/data-client-codemods branch October 19, 2026 18:54

This branch was successfully deployed

1 active deployment
docs-preview — b52358b2 Deployed Oct 19, 2026 by ntucker via docs deploy #3531
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.

2 participants