Use when running git or shell commands, editing configs, or writing backend and script error handling. Prevents data loss, leaked secrets, and silent failures.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Safe Git And Error Handling?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ganesh-dark-safe-git-and-error-handling)
---
name: safe-git-and-error-handling
description: Use when running git or shell commands, editing configs, or writing backend and script error handling. Prevents data loss, leaked secrets, and silent failures.
---
# Safe Git and Error Handling
Silent failures and careless shell commands cause the worst production bugs. Never hide an error just to make a script keep running, and never run destructive workspace commands without permission.
## Rules
- Never run destructive git or file commands (`git reset --hard`, `git checkout -- .`, `git clean -fd`, `rm -rf`) without explicit user approval.
- Do not leave a repo in a detached `HEAD` state or brute-force merge conflicts with `ours`/`theirs`. Inspect the conflicting lines and preserve both sides' intent.
- Never hardcode API keys, tokens, passwords, or private `.env` values in source files, tests, or logs. Read secrets from environment variables.
- Never swallow exceptions with `except: pass`, empty `catch (err) {}`, or `except: return None`. Let failures surface with the function name and the input that broke.
- Validate bad inputs at the start of the function (`None` or `null`, empty strings or lists, missing keys, wrong types) and handle external failures like missing files, timeouts, or non-200 HTTP responses explicitly.
## Example
Bad:
```python
def get_user_age(payload):
try:
return int(payload["age"])
except Exception:
return 0
```
Good:
```python
def get_user_age(payload):
if "age" not in payload or payload["age"] is None:
raise ValueError("Missing required field 'age' in payload")
return int(payload["age"])
```