Agent skill

Python Debug Pattern

by HKUDS in HKUDS/OpenSpace

Debug Python script execution failures by capturing full output with exit codes and verifying working directory before file operations

MITAuto-check passedDevelopment

Install Python Debug Pattern

skills CLI
$ npx skills add HKUDS/OpenSpace --skill python-debug-pattern -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install HKUDS/OpenSpace python-debug-pattern --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/HKUDS/OpenSpace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/benchmarks/gdpval/skills/python-debug-pattern .claude/skills/python-debug-pattern && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
python-debug-pattern
GitHub stars
7.7k
Token cost
~792 tokens
SKILL.md length
263 words
Files
2
Skills in repo
199
Repo updated
First seen
Licence
MIT

At a glance

Debug Python script execution failures by capturing full output with exit codes and verifying working directory before file operations

  • Works in 2 steps: Execute Python Scripts with Full Error… → Verify Working Directory Before File…
  • Tasks that involve Debugging
  • SKILL.md covers Core Technique, When to Apply This Pattern, Quick Checklist and Common Failure Modes This…
  • Calls python3

What it does

Python Debug Pattern is an agent skill from HKUDS/OpenSpace. Debug Python script execution failures by capturing full output with exit codes and verifying working directory before file operations

Its SKILL.md is about 790 tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file.

It sits in Development, covering Debugging. It works with Python. The repository describes itself as: "OpenSpace: The Skill Management Layer for AI Agents" -- https://open-space.cloud/. The licence is MIT.

When your agent uses it

  • Tasks that involve Debugging

Example prompts

  • “/python-debug-pattern”

Requirements

  • Python 3

Workflow steps

2 steps, taken from the step headings in SKILL.md.

  1. Execute Python Scripts with Full Error Capture
  2. Verify Working Directory Before File Operations

What it can do on your machine

Read from SKILL.md and the folder at commit 3827781. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Python Debug Pattern loads about 792 tokens when it runs. Until then it costs about 39 tokens; SKILL.md has 263 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~39
When it runs · the whole SKILL.md, loaded when a task matches
~792

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from HKUDS/OpenSpace at commit 3827781, republished under its MIT licence (© HKUDS). 263 words, ~792 tokens.

Download SKILL.mdSave it as .claude/skills/python-debug-pattern/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
python-debug-pattern
description
Debug Python script execution failures by capturing full output with exit codes and verifying working directory before file operations

Python Debug Pattern

This skill provides a reusable pattern for debugging Python script execution failures. It ensures you capture actual tracebacks instead of opaque errors and verify the working directory before file operations.

Core Technique

1. Execute Python Scripts with Full Error Capture

When running Python scripts, always use this command pattern to surface actual tracebacks:

bash
python3 script.py 2>&1 ; echo Exit code: $?

Why this works:

  • 2>&1 redirects stderr to stdout, capturing both regular output and errors
  • ; echo Exit code: $? displays the actual exit code after execution
  • This reveals the full Python traceback instead of opaque failure messages

Examples:

bash
# Good: Full error capture
python3 process_data.py 2>&1 ; echo Exit code: $?

# Bad: Opaque error (no stderr capture, no exit code)
python3 process_data.py
2. Verify Working Directory Before File Operations

Before any file read/write operations in Python, verify the current working directory:

python
import os

# At script start, log the working directory
print(f"Working directory: {os.getcwd()}")

# For file operations, use absolute paths or log the resolved path
file_path = "output/result.csv"
abs_path = os.path.abspath(file_path)
print(f"Writing to: {abs_path}")

Why this works:

  • Many failures occur because scripts run from unexpected directories
  • Logging the working directory immediately surfaces path-related issues
  • Absolute paths prevent ambiguity in file operations

Full example script structure:

python
#!/usr/bin/env python3
import os
import sys

def main():
    # Debug: verify working directory
    print(f"Working directory: {os.getcwd()}", file=sys.stderr)
    
    # Debug: list directory contents if dealing with files
    print(f"Directory contents: {os.listdir('.')}", file=sys.stderr)
    
    # Your actual logic here
    # ...

if __name__ == "__main__":
    main()

When to Apply This Pattern

  • Python script fails with an opaque error message
  • File operations (read/write) fail unexpectedly
  • Script works locally but fails in automated execution
  • Debugging CI/CD pipeline failures
  • Investigating "file not found" or permission errors

Quick Checklist

  • Run script with 2>&1 ; echo Exit code: $? pattern
  • Add os.getcwd() logging at script start
  • Use os.path.abspath() for file paths
  • Log directory contents with os.listdir('.') if relevant
  • Check for missing dependencies (capture full traceback)

Common Failure Modes This Pattern Surfaces

SymptomWithout PatternWith Pattern
File not found"Error: failed"Full traceback showing exact path attempted
Permission deniedScript exits silentlystderr shows permission error
Missing moduleOpaque exitImportError with module name
Wrong directoryConfusing path errorscwd logged, reveals directory mismatch

© HKUDS, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in benchmarks/gdpval/skills/python-debug-pattern of HKUDS/OpenSpace.

  • SKILL.md
  • .skill_id

Open the folder on GitHubat commit 3827781

Compare with similar skills

Python Debug Pattern next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Python Debug Pattern compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Python Debug Pattern this skillHKUDS/OpenSpace7.7k—~792Automated safety check: PassMIT
LangBot Plugin Developmentlangbot-app/LangBot18k—~3.9kAutomated safety check: PassApache-2.0
Python Performance Optimizationwshobson/agents40k13 repos~814Automated safety check: PassMIT
Git History Bug Auditben-manes/caffeine18k—~3.3kAutomated safety check: PassApache-2.0
Keybase RPC Log Analysiskeybase/client9.3k—~3kAutomated safety check: PassBSD-3-Clause
The Art of Debuggingstas00/the-art-of-debugging1.7k—~6.1kAutomated safety check: NotesCC-BY-SA-4.0

Similar skills

  • LangBot Plugin Development

    langbot-app/LangBot

    Guides building, debugging and testing LangBot plugins: components, SDK calls, README and locale rules, SDK pitfalls and WebSocket-based testing.

    18k GitHub stars~3.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Profiles slow Python code with cProfile and memory profilers, then applies targeted fixes for CPU, memory, I/O and query bottlenecks.

    40k GitHub starsUsed in 13 repos~814 tokens
    DevelopmentAuto-check passed
  • Git History Bug Audit

    ben-manes/caffeine

    Audits a module by walking its git history commit by commit, tracking unresolved issues forward, and reporting the ones that survive to HEAD as findings.

    18k GitHub stars~3.3k tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Captures a clean Keybase service log and analyzes it for redundant, duplicated or looping RPCs, then checks whether a caching fix reduced the calls.

    9.3k GitHub stars~3k tokensUpdated today
    DevelopmentAuto-check passed
  • The Art of Debugging

    stas00/the-art-of-debugging

    Condensed debugging method and tool recipes for Unix, Python and PyTorch programs: crashes, hangs, segfaults, wrong output, CUDA OOM, NaN values and slowness.

    1.7k GitHub stars~6.1k tokensUpdated yesterday
    DevelopmentAuto-check: notes
  • Adk Setup

    google/adk-python

    Official

    Sets up a local ADK Python development environment in a git clone of the open-source adk-python repository: a uv virtual environment, all dependency extras, pre-commit hooks, and a first unit-test…

    22k GitHub stars~993 tokensUpdated today
    DevelopmentAuto-check: notes

More from HKUDS/OpenSpace

All 199 skills in this repo
  • Walks through producing a master audio track plus stems in Python, from checking a reference file and timing sections by BPM to effects, a zip archive and final verification.

    7.7k GitHub stars~2.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Handle cascading data retrieval tool failures by falling back to embedded knowledge generation

    7.7k GitHub stars~765 tokensUpdated 1 mo ago
    Auto-check passed
  • Gives an agent a workaround when its code-execution sandbox keeps failing: save the Python script to a file and run it through the shell instead.

    7.7k GitHub stars~588 tokensUpdated 1 mo ago
    Auto-check passed
  • A recovery routine for agents whose sandboxed code runner keeps failing: save the Python script to disk, then run it through the shell and read the output.

    7.7k GitHub stars~652 tokensUpdated 1 mo ago
    Auto-check passed
  • Fallback ladder for failed sandboxed code runs, plus the habit of fixing the working directory first so generated files land in the right place.

    7.7k GitHub stars~1.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Fallback workflow for executing Python code when executecodesandbox fails repeatedly

    7.7k GitHub stars~1.1k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Categories

Questions about Python Debug Pattern

What does Python Debug Pattern do?

Debug Python script execution failures by capturing full output with exit codes and verifying working directory before file operations. Python Debug Pattern is an agent skill from HKUDS/OpenSpace.

When should I use Python Debug Pattern?

Python Debug Pattern fits situations like: tasks that involve Debugging.

How do I install Python Debug Pattern in Claude Code?

Run `npx skills add HKUDS/OpenSpace --skill python-debug-pattern -a claude-code`. Or copy the skill folder (benchmarks/gdpval/skills/python-debug-pattern in HKUDS/OpenSpace) into .claude/skills/python-debug-pattern in your project. Claude Code loads it when a task matches its description.

How do I install Python Debug Pattern in Codex?

Run `npx skills add HKUDS/OpenSpace --skill python-debug-pattern -a codex`. Or copy the skill folder (benchmarks/gdpval/skills/python-debug-pattern in HKUDS/OpenSpace) into .agents/skills/python-debug-pattern in your project. Codex loads it when a task matches its description.

Can I use Python Debug Pattern in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add HKUDS/OpenSpace --skill python-debug-pattern -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/python-debug-pattern, .gemini/skills/python-debug-pattern, .github/skills/python-debug-pattern and .opencode/skills/python-debug-pattern in your project.

What does Python Debug Pattern need to run?

Going by SKILL.md and its folder, Python Debug Pattern needs the command-line tools its instructions call (python3). Our summary lists: Python 3.

Does Python Debug Pattern access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Python Debug Pattern safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Python Debug Pattern use?

Python Debug Pattern is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Python Debug Pattern use?

About 792 tokens (SKILL.md is roughly 3.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Python Debug Pattern?

Skills that share tags, products or a category with Python Debug Pattern: LangBot Plugin Development (langbot-app/LangBot, 18k stars), Python Performance Optimization (wshobson/agents, 40k stars), Git History Bug Audit (ben-manes/caffeine, 18k stars) and Keybase RPC Log Analysis (keybase/client, 9.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Python Debug Pattern?

HKUDS (a GitHub organization) maintains it in HKUDS/OpenSpace, which has 7,749 GitHub stars. The repository holds 199 skills in this directory. The repository was last updated on August 12, 2026.

Source: HKUDS/OpenSpace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.