Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

scripting-automation

/scripting-automation

Pisze skrypty operacyjne odporne na produkcję: idempotentność, obsługę błędów, kody wyjścia, logowanie i tryb dry-run.

Repozytorium
devops-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
25.08.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 25.08.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pisze skrypty operacyjne odporne na produkcję: idempotentność, obsługę błędów, kody wyjścia, logowanie i tryb dry-run.

Oryginalny opis (EN)

Covers writing operational scripts that survive contact with production — idempotency, real error handling and exit codes, structured logging, a dry-run mode, and recognizing when a script has outgrown scripting. Use this whenever the user is writing a bash or Python script that touches production, asks why a script failed silently or left things half-changed, wants a `--dry-run` flag added, or is deciding whether a script should become a proper tool or service. For chaining scripts into a multi-step process use `workflow-automation`, and for running one on a schedule use `scheduled-jobs`.

Jak działa

  1. 1. Fail loudly and stop, don't limp forward
  2. 2. Make re-running safe by default
  3. 3. Ship a dry-run mode before you ship the real one
  4. 4. Log what happened, not just that something ran
  5. 5. Know when a script should stop being a script
  6. Report
Sekcje z nagłówków SKILL.md, w oryginale · 103 linii, 931 słów
Podgląd SKILL.md
---
name: scripting-automation
description: Covers writing operational scripts that survive contact with production — idempotency, real error handling and exit codes, structured logging, a dry-run mode, and recognizing when a script has outgrown scripting. Use this whenever the user is writing a bash or Python script that touches production, asks why a script failed silently or left things half-changed, wants a `--dry-run` flag added, or is deciding whether a script should become a proper tool or service. For chaining scripts into a multi-step process use `workflow-automation`, and for running one on a schedule use `scheduled-jobs`.
license: MIT
---

# Scripting Automation

A script written for a one-off task gets run again next week, then gets copied to another team,
then ends up wired into a cron job nobody remembers writing. Most ops scripts are, in practice, load
-bearing infrastructure that never got the review a production system would get — and the gap
between "works when I ran it" and "safe for someone else to run at 3am" is exactly where scripting
automation earns its keep.

**A script that fails should fail loudly, leave the system in a known state, and tell the next
person what happened — an assumption baked in silently is a bug you haven't met yet.**

## 1. Fail loudly and stop, don't limp forward

The default in most shells is to keep going after a command fails, which turns one missing file
into a cascade of confusing downstream errors. Explicit failure handling turns "the script did
something weird" into "the script told me exactly where it stopped."

```bash
set -euo pipefail    # exit on error, unset variable, or failed pipe stage
trap 'echo "failed at line $LINENO" >&2' ERR
```

- **Exit non-zero on any real failure**, and use distinct codes for distinct failure classes if a
  caller needs to branch on them.
- **Check preconditions before acting** — required tools installed, required variables set, target
  reachable — and fail before the first side effect, not mid-way through.
- **Never swallow an error to "keep the script clean"** — a silenced failure is a false success
  report to whoever runs it next.

**Done when:** a failure anywhere in the script produces a non-zero exit code and a clear message
naming what failed, with no partial success reported as success.

## 2. Make re-running safe by default

A script that's safe to run once but not twice will eventually be run twice — by a retry, by a
confused operator, by a scheduler that fired while the last run was still cleaning up. Idempotency
is the same discipline `workflow-automation` requires of workflow steps, applied to the script
itself.

- **Check state before changing it** — "does this exist" before "create this."
- **Make partial completion resumable** — if the script dies at step 4 of 7, re-running should pick
  up cleanly, not redo steps 1–3 destructively or skip them incorrectly.
- **Avoid append-only side effects without a guard** — a script that appends a line to a config file
  on every run will eventually append it a hundred times.

**Done when:** running the script twice in a row, including after an interrupted first run,
produces the same end state as running it once.

## 3. Ship a dry-run mode before you ship the real one

The single highest-leverage feature in an ops script is a flag that shows exactly what it would do
without doing it. It catches wrong assumptions before they touch production and gives a reviewer
something concrete to check against intent.

- **`--dry-run` should exercise the real logic path**, not a separate parallel implementation that
  can drift out of sync with what actually runs.
- **Print the specific action, not a generic "would modify resource"** — the operator reviewing
  dry-run output needs to see the actual diff or command.
- **Default to dry-run for anything destructive** and require an explicit flag to go live, not the
  other way around.

**Done when:** every destructive script has a dry-run mode that reflects real execution logic, and
that mode is what a reviewer runs before approving the real one.

## 4. Log what happened, not just that something ran

A script's log is the only record of what it did once the terminal closes. "Done." tells the next
person nothing; a log that names every resource touched, every decision made, and every skip
reason lets them reconstruct the run without re-executing it.

- **Log at the start**: what the script is about to do and against what target.
- **Log every state-changing action** with enough detail to reverse it by hand if needed.
- **Send logs somewhere durable** if the script runs unattended — a local stdout that scrolls off a
  terminal is not a log, it's a rumor.

**Done when:** someone who wasn't watching the terminal can read the log afterward and know exactly
what the script changed.

## 5. Know when a script should stop being a script

A script accumulates flags, retries, and edge-case handling until it's effectively an application
without the tests, ownership, or deployment story of one. That's the point to graduate it — into a
proper CLI, a scheduled job with monitoring, or a service — rather than adding the twentieth flag.

- **Growing beyond a few hundred lines, or beyond one owner's head**, is a graduation signal.
- **Needing its own test suite** to trust changes means it needs the structure a script directory
  doesn't provide.
- **Being invoked by other automation regularly** means its failure mode now affects more than one
  person's terminal — treat it with the rigor of `workflow-automation`.

**Done when:** you can name, honestly, whether this script is still a script or should already be
something else — and if it should, that decision is written down, not deferred indefinitely.

## Report

State the script's failure behavior (exit codes, what stops it), whether it's confirmed idempotent
on a second run, and whether it has a working dry-run mode.

Name the honest gap — usually a code path that hasn't been tested against a mid-run interruption, or
a dry-run mode that's drifted from the real logic — rather than claiming the script is fully
production-safe.

Wersje

RepozytoriumWynikLicencja
Ta strona · arjunprabhulal/devops-skills100MIT
itsmesarath/blender-master90MIT

Migawka bazy z 13.11.2026 · wersja paczki 152db7358ddd (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90shell-scripting-guide
    Pomaga pisać skrypty POSIX sh i Bash: tryb ścisły, cytowanie, kody wyjścia, idempotentność oraz sprawdzanie przez shellcheck.
  • 100ops-scripting-standards
    Pisze skrypty automatyzacji w Bash, PowerShell lub Pythonie: przerywa przy błędach, ma tryb próbny, a drugie uruchomienie nic nie zmienia.
  • 100overview
    Pomaga wybrać język skryptów do automatyzacji IT, np. Bash, PowerShell, Python lub Node.js, i pisać skrypty przenośne.
  • 95bash-script-generator
    Tworzy skrypty bash z parsowaniem argumentów, obsługą błędów, logowaniem i walidacją wejścia, w tym potoki grep, awk i sed oraz narzędzia wiersza poleceń.
  • 100linux-bash-scripting
    Pisze defensywne skrypty Bash dla Linuksa: bezpieczne podstawy, parsowanie argumentów, wzorce produkcyjne i zgodność z ShellCheck, na przykład do automatyzacji, cronów i narzędzi CLI.
  • 90script-idempotency
    Pomaga pisać skrypty bezpieczne przy ponownym uruchomieniu: kroki sprawdź-potem-działaj, zapisy atomowe i tryby dry-run.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.