Skip to content
Back to skills

Execution Guard

ASecurity

Stops a script or subprocess hanging forever on an external API. Use when writing any automated runner that calls Slack, Drive, or a note-taker.

  • 33 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 23, 2026
ai-agentspythongoapi

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 23, 2026

npx -y skills add BrianArfi/ai-second-brain --skill execution-guard --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Execution Guard?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Execution Guard
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/brianarfi-execution-guard/badge)](https://www.skillsdirectory.com/skills/brianarfi-execution-guard)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: execution-guard
description: Stops a script or subprocess hanging forever on an external API. Use when writing any automated runner that calls Slack, Drive, or a note-taker.
---

# Execution Guard Skill

A utility skill to prevent scripts and subprocesses from running indefinitely (hanging). This is critical for automated runners like `daily_update_runner.py` that depend on external APIs (Slack, Fathom, Google Drive).

## Usage

### 1. Functional Timeout (Python Decorator)
Use this to wrap any Python function that might hang (e.g., due to a network request).

```python
from execution_guard import timeout_guard

@timeout_guard(seconds=60)
def fetch_data():
    # If this takes > 60s, a TimeoutException is raised
    pass
```

### 2. Block Timeout (Context Manager)
Use this for arbitrary blocks of code.

```python
from execution_guard import ScriptGuardian, TimeoutException

try:
    with ScriptGuardian(seconds=120):
        # Long running block
        pass
except TimeoutException:
    print("Code block took too long!")
```

### 3. Safe Subprocess Execution
Use this instead of raw `subprocess.Popen` or `subprocess.run` to ensure entire process groups are cleaned up on timeout.

```python
from execution_guard import safe_run_subprocess

result = safe_run_subprocess(["python3", "heavy_script.py"], timeout=300)
if not result["success"]:
    print(f"Failed: {result.get('message', 'Unknown error')}")
```

## Implementation Details
- **Linux**: Uses `signal.SIGALRM` for Python code blocks and `os.killpg` for subprocesses.
- **Windows**: Fallback to standard `subprocess` timeout and no-op for Python blocks (Windows lacks SIGALRM).

Files in this skill

  • SKILL.md1.6 KB
  • scripts/execution_guard.py3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.