superpowers-plus / rules
Cursor rule8 starsChanged 3 days agoMITView on GitHub
shell rules
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,144 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository134 other files it gives its agents.
- AGENTS.mdAGENTS.md
- guidance/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- guidance/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/cli-tools.mdcCursor rule
- .cursor/rules/invariants.mdcCursor rule
- .cursor/rules/javascript.mdcCursor rule
- .cursor/rules/security.mdcCursor rule
- blast-radius-checkSkill
- brainstormingSkill
- branch-flow-gateSkill
- branch-sync-gateSkill
- codebase-reconSkill
- codeowners-drift-auditSkill
- code-review-batterySkill
- cognitive-complexity-refactoringSkill
- debateSkill
- debug-conductorSkill
- dispatching-parallel-agentsSkill
- domain-buildSkill
- evidence-adjudicatorSkill
- executing-plansSkill
- external-cli-auditSkill
- feature-developmentSkill
- field-rename-verificationSkill
- finishing-a-development-branchSkill
- git-branch-conventionsSkill
- gitlab-cliSkill
- hotfix-charterSkill
- implementation-trackerSkill
- incident-revert-reviewSkill
- infra-config-investigatorSkill
- investigation-stateSkill
- kernel-splitSkill
- llm-behavior-investigatorSkill
- llm-skill-reviewSkill
- merge-authorization-gateSkill
- micro-harsh-reviewSkill
- output-verificationSkill
- pre-commit-gateSkill
- progressive-code-review-gateSkill
- progressive-harsh-reviewSkill
- providing-code-reviewSkill
- pr-triage-gateSkill
- push-authorization-gateSkill
- receiving-code-reviewSkill
- reproduction-experiment-investigatorSkill
- requesting-code-reviewSkill
- requirements-validation-pmSkill
- requirements-validationSkill
- scope-tripwireSkill
- session-handoffSkill
- skills-hierarchy-tuningSkill
- sp-bughuntSkill
- state-consistency-investigatorSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- timeline-trace-investigatorSkill
- The first 60 shown.
The file
We split this shell.mdc into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 115
Fix: Test both ./script.sh AND source script.sh
- Very specific: line 120
Fix: Always use set -euo pipefail, check critical operations
- Very specific: line 125
Fix: Use $SCRIPT_DIR pattern, check for required tools
- Distinctive: line 134
Before committing shell scripts:
≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: shell rules
globs: "**/*.sh"
alwaysApply: false
---
# Shell Script Conventions
> **Priority**: HIGH - Apply to all shell scripts
> **Source**: scripts/AGENTS.md (extensive documentation)
## Common Pitfalls to Avoid
### SC2155 - Declare and assign separately
```bash
# ❌ Wrong - masks return value
local output=$(some_command)
# ✅ Correct - preserves return value
local output
output=$(some_command)
```
### Filename Handling
```bash
# ❌ Wrong - breaks on spaces/special chars
for file in $(ls); do
# ✅ Correct - safe iteration
for file in *; do
[[ -e "$file" ]] || continue
```
### Input Sanitization
```bash
# ✅ Always quote variables
"$variable"
# ✅ Use [[ ]] for conditionals (safer than [ ])
if [[ -z "$var" ]]; then
# ✅ Validate inputs before use
[[ -f "$file" ]] || { echo "File not found"; exit 1; }
```
## Script Template
```bash
#!/usr/bin/env bash
set -euo pipefail
# Description: [What this script does]
# Usage: script.sh [options] <args>
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
main() {
# Implementation here
:
}
main "$@"
```
## Pre-Commit Checklist
1. [ ] Run ShellCheck: `shellcheck script.sh`
2. [ ] Test with `set -euo pipefail`
3. [ ] Test with empty inputs
4. [ ] Test with paths containing spaces
5. [ ] Verify works on macOS (BSD tools vs GNU)
6. [ ] Check variable exports for libraries
## Platform Compatibility
macOS uses BSD tools, Linux uses GNU. Common differences:
| Command | macOS (BSD) | Linux (GNU) |
|---------|-------------|-------------|
| sed -i | `sed -i ''` | `sed -i` |
| grep -P | Not available | Available |
| date | Different flags | Different flags |
```bash
# ✅ Portable sed in-place
if [[ "$(uname)" == "Darwin" ]]; then
sed -i '' 's/old/new/' file
else
sed -i 's/old/new/' file
fi
```
## Commands
```bash
# Lint with ShellCheck
shellcheck -x script.sh
# Check syntax
bash -n script.sh
```
---
## Failure Cases & Lessons Learned
> Source: scripts/AGENTS.md - Document failures to prevent recurrence
### Failure 1: Untested Export
**Symptom**: Script works standalone, fails when sourced
**Cause**: Variables not exported for subshells
**Fix**: Test both `./script.sh` AND `source script.sh`
### Failure 2: Silent Data Loss
**Symptom**: Script completes "successfully" but data missing
**Cause**: `set -e` not used, errors not checked
**Fix**: Always use `set -euo pipefail`, check critical operations
### Failure 3: Path Assumptions
**Symptom**: Works on dev machine, fails in CI
**Cause**: Hardcoded paths, assumed tools installed
**Fix**: Use `$SCRIPT_DIR` pattern, check for required tools
### Failure 4: Quote-itis
**Symptom**: Breaks on filenames with spaces
**Cause**: Unquoted variables
**Fix**: Quote everything: `"$var"` not `$var`
## Pre-Commit Validation Checklist
Before committing shell scripts:
1. [ ] `shellcheck -x script.sh` passes
2. [ ] `bash -n script.sh` passes (syntax check)
3. [ ] Test with empty inputs
4. [ ] Test with paths containing spaces
5. [ ] Test sourcing AND direct execution
6. [ ] Verify on both macOS and Linux if cross-platform
<!-- golden-agents:generated -->
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

