refactor-shell

refactor-shell is a skill for Claude Code from natthasath/natthasath-marketplace. It costs 99 tokens per session (1,294 once invoked), scanned A, original, MIT.

A guide for creating and refactoring shell scripts, which are programs that automate commands in a terminal. It covers structure, naming, validation, error handling, logging, and exit codes.

In plain words
What is it for?
Use it to build or improve Bash scripts for tasks such as backups and deployment automation.
Why use it?
It helps scripts fail clearly and predictably instead of silently producing incomplete or unsafe results.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter.

Part of the refactor plugin — 5 skills shipped together

Good fit Use it to build or improve Bash scripts for tasks such as backups and deployment automation.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/natthasath/natthasath-marketplace/refactor-shell
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 natthasath/natthasath-marketplace --skill refactor-shell
Clone the repo
git clone --depth 1 https://github.com/natthasath/natthasath-marketplace

Made for: Claude Code.

Or install refactor, the plugin that ships this one along with the rest of its 5 skills.

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 refactor-shell

README.md
[![agentmods](https://agentmods.dev/badge/skills/natthasath/natthasath-marketplace/refactor-shell/github.svg)](https://agentmods.dev/skills/natthasath/natthasath-marketplace/refactor-shell)
Your own site
<a href="https://agentmods.dev/skills/natthasath/natthasath-marketplace/refactor-shell"><img src="https://agentmods.dev/badge/skills/natthasath/natthasath-marketplace/refactor-shell/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 refactor-shell

Your own site · 80×15
<a href="https://agentmods.dev/skills/natthasath/natthasath-marketplace/refactor-shell"><img src="https://agentmods.dev/badge/skills/natthasath/natthasath-marketplace/refactor-shell.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 99 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,294 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.
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.00099 $0.01294
Opus 5.5 $0.00040 $0.00518
Sonnet 5.5 $0.00020 $0.00259
Haiku 4.5 $0.00010 $0.00129

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

Security

Grade A, and why

refactor-shell 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 2mo 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.

plugins/refactor/skills/refactor-shell/SKILL.md · 84 lines

How it starts

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

Shell Script Standardizer

สร้างไฟล์ Shell Script สำหรับ {xxx} และช่วยปรับปรุงโครงสร้างและ code ของ Shell Script ให้เป็นไปตามมาตรฐานการพัฒนาที่ดี และเรียงลำดับ properties ตามหลักการต่อไปนี้:

shell script ที่มีโครงสร้างดีอ่านง่าย debug ง่าย และลด human error เพราะมี error handling และ logging เป็นระบบ — script ที่ดีควรเป็นเหมือน documentation ของตัวเองได้

Core Rules (Non-negotiable)

  1. ตอบแบบ Artifact เสมอ เพื่อให้นำไปใช้งานได้ทันที
  2. ตอบเป็นภาษาไทย (อธิบาย) พร้อม code ภาษา Bash
  3. ปรับให้ครบทุกข้อตามมาตรฐานใน Workflow ไม่ใช่เลือกทำบางข้อ
  4. ไม่ต้องอธิบายเหตุผลในทุกบรรทัด — แต่หากมีข้อเสนอแนะในการปรับปรุง script ที่ต่างออกไปจากมาตรฐาน ให้เสนอมาพร้อมอธิบายเหตุผล
  5. ใช้ skill นี้ทันทีเมื่อผู้ใช้ต้องการ automate งานบน command line หรือแชร์ script ที่ต้องการปรับปรุง แม้จะไม่ได้ขอ refactor โดยตรง

Workflow

1. โครงสร้าง Shell Script

ปรับแต่ง script ให้เรียงลำดับและจัดกลุ่มตามมาตรฐาน:

- #!/bin/bash
- คำอธิบาย script และการใช้งาน
- ประกาศตัวแปรค่าคงที่ (Constants)
  - TIMEZONE="Asia/Bangkok"
  - ตัวแปรอื่นๆ
- ประกาศฟังก์ชัน (Functions)
- การตรวจสอบเงื่อนไขก่อนทำงาน
- โค้ดหลัก (Main execution)
- สรุปผลการทำงาน

2. Naming Convention

  • ตัวแปรค่าคงที่: ใช้ตัวพิมพ์ใหญ่ทั้งหมด เช่น INPUT_FILE, CONFIG_DIR, TIMEZONE
  • ตัวแปรทั่วไป: ใช้ตัวพิมพ์เล็ก และ underscore เช่น current_item, total_count
  • ฟังก์ชัน: ใช้ตัวพิมพ์เล็ก และ underscore เช่น check_dependencies(), process_item()
  • ชื่อฟังก์ชันควรสื่อถึงการกระทำ (action verb) เช่น validate_input(), execute_command()

3. การจัดการข้อผิดพลาด

  • กำหนดฟังก์ชัน error_exit() สำหรับแสดงข้อผิดพลาดและออกจากโปรแกรม
  • ตรวจสอบพารามิเตอร์และเงื่อนไขก่อนทำงาน
  • กำหนดค่า return code ที่ชัดเจน (0=success, 1=general error, 2=missing dependencies)

4. ฟังก์ชัน

แยกโค้ดเป็นฟังก์ชันตามความรับผิดชอบดังนี้:

  • log_message() - บันทึกข้อความลงไฟล์ log
  • check_dependencies() - ตรวจสอบโปรแกรมที่จำเป็น
  • validate_input() - ตรวจสอบความถูกต้องของ input
  • process_item() - ประมวลผลรายการแต่ละรายการ
  • execute_command() - รันคำสั่งหลัก
  • display_summary() - แสดงผลสรุป

Read the full file on GitHub · 84 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. 2mo ago Changed · +9 lines 4c41ac8c7e36
  2. 2mo ago First seen · 75 lines · 99 tokens per session scan A 1790a7541f9f

Subscribe to this mod's changes

refactor-shell is a skill published in the GitHub repository natthasath/natthasath-marketplace (1 stars, last pushed 13d ago), licensed MIT. It adds 99 tokens to every session and 1,294 once invoked, about $0.0004 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-09-09.

Related

refactor-shell compared with skills from other repositories

refactor-shell next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactor-shellnatthasath/natthasath-marketplaceSkill113d agoMITA99Claude Code
estimating-and-contingencycbrock84/headcountSkill2.6kyesterdayMITA87Claude Code
support-operationscbrock84/headcountSkill2.6kyesterdayMITA77Claude Code
voice-of-customercbrock84/headcountSkill2.6kyesterdayMITA82Claude Code
ai-ml-governancecbrock84/headcountSkill2.6kyesterdayMITA83Claude Code
seo-strategycbrock84/headcountSkill2.6kyesterdayMITA74Claude Code
customer-onboarding-and-implementationcbrock84/headcountSkill2.6kyesterdayMITA94Claude Code