generic_bash_style

Rules for Bash scripts, which are command-line programs commonly used to automate developer and server tasks. They cover script setup and readable, color-aware status messages.

In plain words
What is it for?
Use them when checking Bash scripts for the required shebang, strict settings, conditional tracing, and the specified note, information, success, and related logging functions.
Why use it?
They give scripts consistent failure handling, debugging behavior, formatting, and output so problems are easier to notice and diagnose.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/abderrahimghazali/cursor-rules/generic_bash_style
Clone the repo
git clone --depth 1 https://github.com/abderrahimghazali/cursor-rules

Made for: Cursor.

Per session 9 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 958 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 91% copy Near-identical to another mod 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 $0.00009 $0.00958
Opus 5 $0.00005 $0.00479
Sonnet 5 $0.00002 $0.00192
Haiku 4.5 $0.00001 $0.00096

Measured yesterday against content hash 0267902a76f1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

generic_bash_style 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 yesterday.

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.

Origin

This is a copy

91% identical to generic_bash_style — 93 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.cursor/rules/generic_bash_style.mdc · 71 lines

What it actually says

Enhanced Bash Scripting Standard with Colorized Logging

This rule enforces best practices for writing Bash scripts, with an emphasis on using colorized logging for better output readability.

actions:

  • type: enforce conditions:

    • pattern: "^#!/usr/bin/env bash$" message: "All scripts should start with the shebang '#!/usr/bin/env bash'."

    • pattern: "^set -eu$" message: "Enable 'set -eu' for script robustness."

    • pattern: "^set -x$" pattern_negate: "^\[ "\${DEBUG-}" = "1" ] && set -x$" message: "Use conditional 'set -x' based on debug flag."

    • pattern: "^# @formatter:off$" message: "Start of formatting block for log functions."

    • pattern: "note\(\) { printf " %s\n" "\${1}"; }$" message: "Include 'note' function for plain messages."

    • pattern: "info\(\) { \[ "\${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\\033\[34m\[INFO] %s\\033\[0m\n" "\${1}" || printf "\[INFO] %s\n" "\${1}"; }$" message: "Include 'info' function for blue informational messages."

    • pattern: "pass\(\) { \[ "\${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\\033\[32m\[ OK ] %s\\033\[0m\n" "\${1}" || printf "\[ OK ] %s\n" "\${1}"; }$" message: "Include 'pass' function for green success messages."

    • pattern: "fail\(\) { \[ "\${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\\033\[31m\[FAIL] %s\\033\[0m\n" "\${1}" || printf "\[FAIL] %s\n" "\${1}"; }$" message: "Include 'fail' function for red error messages."

    • pattern: "warn\(\) { \[ "\${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\\033\[33m\[WARN] %s\\033\[0m\n" "\${1}" || printf "\[WARN] %s\n" "\${1}"; }$" message: "Include 'warn' function for yellow warning messages."

    • pattern: "^# @formatter:on$" message: "End of formatting block for log functions."

  • type: suggest message: | Bash Scripting Best Practices:

    • Error Handling: Use set -eu to catch errors and undefined variables early.
    • Debugging: Implement conditional debugging with set -x using a DEBUG variable.
    • Logging Functions: Use colorized logging for better script output readability:
      • note() for plain notes
      • info() for blue informational messages
      • pass() for green success messages
      • fail() for red error messages
      • warn() for yellow warnings, ensuring users can distinguish different types of messages easily
    • Security: Avoid using eval or similar constructs; use safe alternatives.
    • Documentation: Include descriptive comments, especially for complex logic.
    • Portability: Use /usr/bin/env bash for the shebang to ensure script runs with bash on any system.
    • Variable Checks: Ensure necessary variables are set, enhancing script reliability.
    • Exit Codes: Use explicit exit codes for different failure scenarios.
    • Color Support: Ensure logging functions check for terminal color support before applying colors.

metadata: priority: medium version: 1.1

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. yesterday First seen · 71 lines · 9 tokens per session scan A 0267902a76f1

Subscribe to this mod's changes

generic_bash_style is a cursor rule published in the GitHub repository abderrahimghazali/cursor-rules (2 stars, last pushed 1y ago), licensed MIT. It adds 9 tokens to every session and 958 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. It is 91% identical to generic_bash_style, differing in 93 lines, and is treated as a copy.