refactor-shell

Creates and refactors Bash shell scripts with structured error handling and logging.

1|Updated Jun 29, 2026
One-click install
npx skills add https://github.com/natthasath/natthasath-marketplace --skill refactor-shell-natthasath
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: refactor-shell
Source: https://github.com/natthasath/natthasath-marketplace/tree/main/plugins/refactor/skills/refactor-shell
Command: npx skills add https://github.com/natthasath/natthasath-marketplace --skill refactor-shell-natthasath

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Shell scripts often grow into unstructured, hard-to-debug files without error handling or logging, causing silent failures and human error in automation tasks. This Skill restructures or generates Bash scripts following standard conventions so they are readable, debuggable, and self-documenting. ## Core Features & Use Cases - Standardized Script Structure: Organizes scripts into shebang, documentation header, constants, functions, precondition checks, main execution, and summary sections. - Error Handling & Logging: Adds error_exit() with clear return codes, a unified log_message() function with timestamps, and INFO/WARNING/ERROR severity levels. - Production Conventions: Enforces naming conventions (UPPERCASE constants, lowercase functions with action verbs), signal traps, command-line parameters, progress indicators, and verbose/silent modes. - Use Case: You have a messy backup script that fails silently. Invoke this Skill with the script path to get a refactored version with dependency checks, input validation, logging, and a run summary. ## Quick Start Run /refactor-shell with the path to your .sh file or a description of the automation task you want scripted.

Frequently Asked Questions about refactor-shell

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor a Bash script to follow best practices?▼

Invoke /refactor-shell with the path to your .sh file. The script is restructured into standard sections: constants, functions, precondition checks, main execution, and summary, with error handling and logging added throughout.

How to add error handling and logging to a shell script?▼

This Skill adds an error_exit() function with distinct return codes (0 success, 1 general error, 2 missing dependencies) and a log_message() function with consistent timestamps and INFO, WARNING, and ERROR severity levels.

Can I generate a new Bash script from a task description?▼

Yes. Provide a description of the automation task, such as database backup or deployment, and the Skill generates a complete script template covering all six structural sections without asking follow-up questions.

Does this skill auto-trigger when I share a shell script?▼

No. The Skill has model invocation disabled and only runs when explicitly called via /refactor-shell. Sharing a script in conversation alone will not activate it.

What naming conventions does the refactored shell script use?▼

Constants use all-uppercase names like INPUT_FILE, regular variables use lowercase with underscores, and functions use lowercase action-verb names such as validate_input() and execute_command().