Scope a JavaScript to Strict TypeScript Codex Task
Generate a precise execution prompt for OpenAI Codex to migrate legacy JavaScript files to strict TypeScript with zero any types and test verification.
Agent prompt for ChatGPT
You get: Task Overview, constraints Checklist and codex Directive
Prompt
mkdir -p .agents/skills/scope-a-javascript-to-strict-typescript-codex-task && curl -sL "https://prompts-gpt.com/prompts/scope-a-javascript-to-strict-typescript-codex-task/raw" -o .agents/skills/scope-a-javascript-to-strict-typescript-codex-task/SKILL.mdAct as a principal TypeScript engineer writing a scoped task file for OpenAI Codex.
I will paste the legacy JavaScript code or describe the target module right after this prompt.
Your job is to generate an execution prompt for Codex that guides it to convert the file to strict TypeScript without modifying business logic.
Rules for the generated Codex prompt:
1. Rename the file from .js to .ts and enforce strict mode.
2. Ban the 'any' keyword completely; require explicit interfaces or generics for all function arguments and returns.
3. Keep internal function bodies untouched unless an explicit type narrowing check is required.
4. Mandate a verification step using a project typecheck command (e.g., npx tsc --noEmit) before completing the task.
Output format:
- Task Overview: One line stating the exact input and output file paths.
- Constraints Checklist: Bullet list of strict typing boundaries Codex must respect.
- Codex Directive: The copy-paste block of instructions for Codex CLI or AGENTS.md.
- Verification Command: The shell command Codex must run to confirm zero type errors.
State one runtime risk involving dynamic object mutations that static types cannot catch.Example output
Tips and common edits
Why this works
- Strictly bans the any keyword to stop Codex from creating loose or meaningless type definitions.
- Limits refactoring to function boundaries to prevent Codex from unintentionally altering working business logic.
- Includes a deterministic CLI validation command so Codex can verify its work before terminating.
Paste your legacy JavaScript code snippet directly below the prompt in ChatGPT or Codex CLI to get an automated, risk-contained migration specification.
Common edits
- Swap the verification command to pnpm typecheck or your custom monorepo build script.
- Specify existing shared types Codex should import instead of creating local interfaces.
Reuse it: Use in a workflowAdapt in the builder
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
More like this
Optimize Cursor Workspace Context for AI Agents
Analyze your project directory to identify non-essential files and generate a precise .cursorignore file that keeps context windows clean and efficient.
Reconcile OpenAPI Schema Drift with Backend Logic
Get a three-column alignment matrix that identifies discrepancies between your OpenAPI spec, TypeScript client types, and actual backend request validation logic.
Create a Legacy Module Reference Sheet for Coding Agents
Compresses messy legacy source files into a dense markdown cheat sheet capturing public methods, hidden state changes, and side effects for coding agent contexts.
Debug Regex and Parsers with GitHub Copilot
Generate an automated audit of regular expressions or parser snippets that flags catastrophic backtracking, isolates edge cases, and produces unit test fixtures.
Build a Color Sequence Memory Game with Synth Tones in One HTML File
A ready-to-paste prompt that builds Echo Garden, a four-pad color-and-shape sequence memory game with Web Audio tones, a strict mode and rising speed.
Build a Countdown Timer to Any Date With a Confetti Finish in One HTML File
Get a polished single-file countdown page with a custom event title, a large days-hours-minutes-seconds display and a confetti-and-chime celebration at zero.
- Build a Keyboard-Friendly To-Do Checklist with Priorities and Filters in One HTML File
- Build a Reaction Time Tester Game with False-Start Detection in One HTML File
- Build an Animated Headline Text Reveal Playground in a Single HTML File
- Build an Instant Two-Way Unit Converter With Kitchen Measurements in HTML
- Build a Budget Allocation Treemap Infographic in a Single HTML File
- Convert a pasted JSON payload into typed interfaces