javascript-refactoring

javascript-refactoring is a skill for Claude Code, Codex from github/gh-aw. It costs 15 tokens per session (1,909 once invoked), scanned A, original, MIT.

A guide for splitting large JavaScript files into smaller CommonJS modules, a format that uses require and module.exports to share code.

In plain words
What is it for?
Use it when refactoring JavaScript used by gh-aw workflows, especially code embedded in Go and executed through GitHub Actions.
Why use it?
It helps make workflow scripts easier to maintain and test without breaking the way the project bundles and runs them in GitHub Actions.

Skill for Claude CodeCodex ✓ vendor

Written for no agent in particular: nothing here depends on one.

Good fit Use it when refactoring JavaScript used by gh-aw workflows, especially code embedded in Go and executed through GitHub Actions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/github/gh-aw/javascript-refactoring
About the project

GitHub Agentic Workflows is a GitHub CLI extension that lets developers define AI-assisted repository automation in Markdown and run it through GitHub Actions. It is intended for tasks requiring interpretation or reasoning, such as issue triage, pull-request review, CI investigation, documentation maintenance, and dependency analysis. The catalogue entries provide skills and agents for working with these workflows.

github/gh-aw · 5,579 stars · on GitHub · gh.io

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add github/gh-aw --skill javascript-refactoring
Clone the repo
git clone --depth 1 https://github.com/github/gh-aw

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for javascript-refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/github/gh-aw/javascript-refactoring/github.svg)](https://agentmods.dev/skills/github/gh-aw/javascript-refactoring)
Your own site
<a href="https://agentmods.dev/skills/github/gh-aw/javascript-refactoring"><img src="https://agentmods.dev/badge/skills/github/gh-aw/javascript-refactoring/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for javascript-refactoring

Your own site · 80×15
<a href="https://agentmods.dev/skills/github/gh-aw/javascript-refactoring"><img src="https://agentmods.dev/badge/skills/github/gh-aw/javascript-refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 15 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,909 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00015 $0.01909
Opus 5.5 $0.00006 $0.00764
Sonnet 5.5 $0.00003 $0.00382
Haiku 4.5 $0.00002 $0.00191

Measured 1mo ago against content hash 5ff045a9d379, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

javascript-refactoring scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/skills/javascript-refactoring/SKILL.md · 249 lines

How it starts

The opening of the file, as written. The whole thing — 249 lines — stays where its author put it; the contents beside it link to each section on GitHub.

JavaScript Code Refactoring Guide

Use this guide to split JavaScript into maintainable CommonJS modules in gh-aw without drifting into dead embedding patterns.

Overview

The current gh-aw architecture is action-centric:

  • Shared JS modules live under pkg/workflow/js/*.cjs and actions/setup/js/*.cjs
  • Action source files live under actions/<action-name>/src/
  • Generated action bundles are committed under actions/<action-name>/index.js
  • Shipping is driven by the action build pipeline (make actions-build, gh aw actions-build) and dependency maps such as pkg/cli/actions_build_command.go
  • pkg/workflow/js.go is a stub; it no longer owns the runtime JavaScript shipping path for the main workflows

If you are refactoring a workflow utility, prefer the current action/module architecture over any older //go:embed pattern.

Top-Level Script Pattern

Top-level .cjs scripts executed directly in workflows follow this pattern:

✅ Correct Pattern - Export main, but don't call it:

async function main() {
  // Script logic here
  core.info("Running the script");
}

module.exports = { main };

❌ Incorrect Pattern - Don't call main in the file:

async function main() {
  // Script logic here
  core.info("Running the script");
}

await main(); // ❌ Don't do this!

module.exports = { main };

Why this pattern?

  • The workflow bundler or action build step can wrap the script with await main() at execution time
  • The module stays importable for tests while still being executable in GitHub Actions
  • It makes unit testing easier and preserves a clean module boundary

Step 1: Put the code in the right source tree

Choose the correct location for the module before writing code:

  • Shared workflow utilities: pkg/workflow/js/
  • Action-specific JavaScript: actions/<action-name>/src/ or actions/setup/js/
  • Generated bundle output: actions/<action-name>/index.js

File naming convention:

  • Use snake_case for filenames (for example sanitize_content.cjs, load_agent_output.cjs)
  • Use .cjs for CommonJS modules
  • Keep the name aligned with the responsibility of the module

Read the full file on GitHub · 249 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed · +10 lines 5ff045a9d379
  2. 2mo ago Changed · -247 lines 974ab2185233
  3. 2mo ago First seen · 486 lines · 15 tokens per session scan A 3a65569b7595

Subscribe to this mod's changes

javascript-refactoring is a skill published in the GitHub repository github/gh-aw (5,579 stars, last pushed yesterday), licensed MIT. It adds 15 tokens to every session and 1,909 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

javascript-refactoring compared with skills from other repositories

javascript-refactoring next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
javascript-refactoringgithub/gh-awSkill5.6kyesterdayMITA15Claude Code, Codex
watch-prjustincampbell/gh-watchSkill47d agoMITA48Claude Code
watch-tagjustincampbell/gh-watchSkill47d agoMITA62Claude Code
watch-branchjustincampbell/gh-watchSkill47d agoMITA45Claude Code
watch-commitjustincampbell/gh-watchSkill47d agoMITA48Claude Code
c-githubdaxaur/openpawSkill1775mo agoMITA48Claude Code, Codex
update-architecture-docsAlexSkrypnyk/scaffoldSkill11yesterdayGPL-3.0A46Claude Code