Agent skill

Structural Refactor

by nklisch in nklisch/claude-code-modes

Project structural organization rules for Bun/TypeScript CLI.

MITAuto-check: notesDevelopment

Install Structural Refactor

skills CLI
$ npx skills add nklisch/claude-code-modes --skill structural-refactor -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install nklisch/claude-code-modes structural-refactor --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/nklisch/claude-code-modes.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/structural-refactor .claude/skills/structural-refactor && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
structural-refactor
GitHub stars
116
Token cost
~526 tokens
SKILL.md length
193 words
Files
8 (incl. references)
Skills in repo
4
Repo updated
First seen
Licence
MIT

At a glance

Project structural organization rules for Bun/TypeScript CLI.

  • Tasks that involve Refactoring
  • SKILL.md covers Rules and Output
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Structural Refactor is an agent skill from nklisch/claude-code-modes. Project structural organization rules for Bun/TypeScript CLI. Proactively scans for organizational issues and produces a prioritized plan. Defines file, folder, and module structure preferences.

Its SKILL.md is about 530 tokens, which your agent loads only when the skill is triggered. The skill folder holds 8 other files, including reference files (for example `references/centralized-types.md`, `references/file-size-limit.md` and `references/flat-by-default.md`).

It sits in Development, covering Refactoring. It works with TypeScript. The repository describes itself as: CLI launcher for Claude Code with behaviorally-tuned system prompts — control agency, quality, and scope instead of fighting the defaults. The licence is MIT.

When your agent uses it

  • Tasks that involve Refactoring

Example prompts

  • “/structural-refactor”

Requirements

  • Pre-approved tools (allowed-tools): Read, Glob, Grep, Bash, Agent, Write

What it can do on your machine

Read from SKILL.md and the folder at commit 4dbbb28. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Glob
    • Grep
    • Bash
    • Agent
    • Write

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Structural Refactor loads about 526 tokens when it runs, and up to ~4.1k if it reads all its reference files. Until then it costs about 54 tokens; SKILL.md has 193 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~54
When it runs · the whole SKILL.md, loaded when a task matches
~526
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Glob, Grep, Bash, Agent, Write

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from nklisch/claude-code-modes at commit 4dbbb28, republished under its MIT licence (© nklisch). 193 words, ~526 tokens.

Download SKILL.mdSave it as .claude/skills/structural-refactor/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.
name
structural-refactor
description
Project structural organization rules for Bun/TypeScript CLI. Proactively scans for organizational issues and produces a prioritized plan. Defines file, folder, and module structure preferences.
allowed-tools
Read, Glob, Grep, Bash, Agent, Write
user-invocable
true

Structural Refactor

Scan the codebase for organizational issues based on these structural rules. Each rule has a reference file with rationale, examples, and exceptions.

Rules

RuleSummary (one line)Reference
Flat by DefaultKeep src/ flat; group into subdirectories only when 3+ files share a concerndetails
Soft 300-Line LimitImplementation files should stay under 300 lines; split when single-domain logic exceeds itdetails
Test Co-locationUnit tests next to source (file.test.ts); integration/e2e tests also in src/details
Centralized TypesAll domain types/interfaces/enums in types.ts; no local type definitionsdetails
No Barrel ExportsNo index.ts re-export files; always import directly from the source moduledetails
Prompt Domain OrganizationPrompts organized by domain concept (axis/modifier), not by implementationdetails
kebab-case FilesAll source files use kebab-case; test files use {source}.test.ts suffixdetails

Output

Write the refactoring plan to docs/structural-refactor-plan.md.

The document should be a prioritized refactoring plan with these sections:

High Value

Implement-ready entries with file paths, current layout, target layout, and acceptance criteria.

Worth Considering

Valid reorganizations with moderate impact. Brief entries with paths and rationale.

Not Worth It

Code that technically violates a rule but should NOT be reorganized, with explanation why.

© nklisch, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 7 other files (references) in .claude/skills/structural-refactor of nklisch/claude-code-modes.

  • SKILL.md
  • references/centralized-types.md
  • references/file-size-limit.md
  • references/flat-by-default.md
  • references/kebab-case-files.md
  • references/no-barrel-exports.md
  • references/prompt-domain-org.md
  • references/test-colocation.md

Open the folder on GitHubat commit 4dbbb28

Compare with similar skills

Structural Refactor next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Structural Refactor compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Structural Refactor this skillnklisch/claude-code-modes116—~526Automated safety check: NotesMIT
Svelte5 Best PracticesSikandarJODD/cnblocks4301 repos~810Automated safety check: PassMIT
Dinero Best Practicesdinerojs/dinero.js6.8k—~756Automated safety check: PassMIT
Code Guidelinesgetsentry/sentry-react-native1.8k—~3.2kAutomated safety check: PassMIT
AST Visitor Pattern for Unionsprisma/orm48k—~830Automated safety check: PassApache-2.0
ast-grep Codemod Referencewarp-drive-data/warp-drive3.2k—~2.6kAutomated safety check: PassMIT

Similar skills

  • Svelte5 Best Practices

    SikandarJODD/cnblocks

    Svelte 5 runes, snippets, SvelteKit patterns, and modern best practices for TypeScript and component development.

    430 GitHub starsUsed in 1 repo~810 tokens
    DevelopmentAuto-check passed
  • Dinero Best Practices

    dinerojs/dinero.js

    Core best practices for the Dinero.js money library. An agent skill from dinerojs/dinero.js.

    6.8k GitHub stars~756 tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Code Guidelines

    getsentry/sentry-react-native

    Official

    Enforce Sentry React Native SDK code guidelines for implementation, refactoring, and review.

    1.8k GitHub stars~3.2k tokensUpdated today
    DevelopmentAuto-check passed
  • Official

    Replaces a plain TypeScript union plus switch statements with frozen subclasses and a visitor interface when several places dispatch on the same variants.

    48k GitHub stars~830 tokensUpdated yesterday
    DevelopmentAuto-check passed
  • ast-grep Codemod Reference

    warp-drive-data/warp-drive

    Reference for writing and debugging TypeScript and JavaScript codemods with @ast-grep/napi: parsing, node queries, meta-variables, rule objects and editing.

    3.2k GitHub stars~2.6k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Deep Refactor Audit

    AlmanacCode/codealmanac

    A skill your agent uses when a user asks for a major architecture/refactor audit, codebase smell investigation, boundary critique, feature simplification review, vibe-coded or AI-generated code…

    998 GitHub stars~3.5k tokensUpdated 2 mo ago
    DevelopmentAuto-check passed

More from nklisch/claude-code-modes

  • Sync Upstream

    nklisch/claude-code-modes

    Compare this project's base prompts and model metadata against a Claude Code release.

    116 GitHub stars~1.8k tokensUpdated 6 days ago
    Auto-check: notes
  • Stylistic Refactor

    nklisch/claude-code-modes

    Project stylistic refactoring rules for Bun/TypeScript CLI. An agent skill from nklisch/claude-code-modes.

    116 GitHub stars~523 tokensUpdated 6 days ago
    Auto-check: notes
  • Patterns

    nklisch/claude-code-modes

    Project code patterns and conventions. An agent skill from nklisch/claude-code-modes.

    116 GitHub stars~228 tokensUpdated 6 days ago
    Auto-check passed

Works with

Categories

Questions about Structural Refactor

What does Structural Refactor do?

Project structural organization rules for Bun/TypeScript CLI. Structural Refactor is an agent skill from nklisch/claude-code-modes. Project structural organization rules for Bun/TypeScript CLI.

When should I use Structural Refactor?

Structural Refactor fits situations like: tasks that involve Refactoring.

How do I install Structural Refactor in Claude Code?

Run `npx skills add nklisch/claude-code-modes --skill structural-refactor -a claude-code`. Or copy the skill folder (.claude/skills/structural-refactor in nklisch/claude-code-modes) into .claude/skills/structural-refactor in your project. Claude Code loads it when a task matches its description.

How do I install Structural Refactor in Codex?

Run `npx skills add nklisch/claude-code-modes --skill structural-refactor -a codex`. Or copy the skill folder (.claude/skills/structural-refactor in nklisch/claude-code-modes) into .agents/skills/structural-refactor in your project. Codex loads it when a task matches its description.

Can I use Structural Refactor in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add nklisch/claude-code-modes --skill structural-refactor -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/structural-refactor, .gemini/skills/structural-refactor, .github/skills/structural-refactor and .opencode/skills/structural-refactor in your project.

What does Structural Refactor need to run?

SKILL.md names no scripts, command-line tools or credentials: Structural Refactor is instructions for the agent only. Its frontmatter pre-approves these tools: Read, Glob, Grep, Bash, Agent, Write.

Does Structural Refactor access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Structural Refactor safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Structural Refactor use?

Structural Refactor is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Structural Refactor use?

About 526 tokens (SKILL.md is roughly 2.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.5k tokens, read only when the agent opens those files.

What are the alternatives to Structural Refactor?

Skills that share tags, products or a category with Structural Refactor: Svelte5 Best Practices (SikandarJODD/cnblocks, 430 stars), Dinero Best Practices (dinerojs/dinero.js, 6.8k stars), Code Guidelines (getsentry/sentry-react-native, 1.8k stars) and AST Visitor Pattern for Unions (prisma/orm, 48k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Structural Refactor?

nklisch (a GitHub user) maintains it in nklisch/claude-code-modes, which has 116 GitHub stars. The repository holds 4 skills in this directory. The repository was last updated on October 1, 2026.

Source: nklisch/claude-code-modes on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.