Python Code Assistant

VerifiedSafe

Generates, analyzes, debugs, and tests Python code using only local context. It inspects the Python environment, reads docstrings and offline documentation to craft solutions, and suggests pip or conda commands for missing packages. Helps when you need to produce or improve Python code without internet access.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude CodeCopilot
#python#code-generation#debugging#testing#local-environment

Recommended for

Automated summary

Generates, analyzes, debugs, and tests Python code using only local context without external web searches.

Strengths

  • Operates offline, protecting privacy and data security.
  • Provides structured documentation directly from the local environment.
  • Suggests pip or conda commands for installing missing dependencies.
  • Analyzes existing code structure (imports, classes, functions).

Limitations

  • Cannot access online resources or the very latest API documentation.
  • Documentation depends on installed versions, which might be outdated.
  • Can be slow on very large projects with many dependencies.
When to use it

Use this skill when working offline or in a sensitive environment where web access is restricted and you need Python code assistance.

When not to use it

Avoid this skill when you need the latest documentation or APIs not available locally, or if the project is too large for quick analysis.

Security analysis

Safe
Quality score90/100

The skill performs only local introspection and analysis using bundled scripts; it does not fetch external resources, execute destructive commands, or exfiltrate data. While it can suggest package installations, it only does so when a requested library is absent and does not automatically install them.

No concerns found

How this analysis is made

Examples

Check package and get documentation
Check if pandas is installed and show me the documentation for DataFrame.merge, including signature, parameters, and example usage.
Analyze existing code
Analyze the file utils.py in my project. List all imports, third-party dependencies, functions, and classes. Suggest any refactoring opportunities.

name: python-code-assistant description: | Generates, analyzes, debugs and tests Python code using only local context. This skill inspects the local Python environment, reads docstrings and offline documentation from installed packages, and synthesizes example patterns found in the workspace to produce high‑quality solutions. It never performs external web searches to gather information, instead relying on what is available locally. When a requested library is missing, the skill returns the appropriate command to install it via pip or conda. license: MIT compatibility: | Works with any agent runtime that supports the open Agent Skills specification and can execute shell and Python commands (e.g. Claude Code, OpenCode, VS Code Copilot agents). The skill assumes access to the local filesystem and a Python interpreter. allowed-tools: Bash Python Read Write metadata: author: spkc83 & Opencode version: "2.0.0"

Python Code Assistant Skill

This skill equips an agent to build and refine Python programs without reaching out to the internet for help. It introspects the local environment, examines code and documentation on disk, and proposes installation steps for missing dependencies. Typical use cases include generating new scripts, debugging existing code, refactoring functions, inspecting package APIs and versions, and writing tests.

Purpose

  • Detect which packages and versions are already installed.
  • Map package names to import names (e.g., Pillow → PIL).
  • Retrieve structured documentation for Python objects including signatures, parameters, types, examples, and related functions.
  • Parse existing Python files to understand their structure and dependencies.
  • Generate new code using idiomatic patterns found locally.
  • Suggest pip or conda commands to install missing packages when needed.
  • Produce simple unit tests and run them to validate generated code.

How to Use

1. Check Package Availability

Before writing code that uses external libraries, check if they're installed:

# Check if a specific package is installed
python scripts/inspect_env.py --package pandas

# Find which package provides an import name
python scripts/inspect_env.py --find-import PIL
# Returns: {"import_name": "PIL", "package": "pillow"}

# Get full environment with all packages
python scripts/inspect_env.py

If a required library is absent, suggest installation:

pip install <package>
# or
conda install <package> -y

2. Lookup Documentation

Get structured documentation for any Python object:

# Get structured JSON documentation
python scripts/doc_lookup.py json.dumps

# Get raw pydoc text (legacy mode)
python scripts/doc_lookup.py pandas.DataFrame.merge --raw

The structured output includes:

  • signature: Full function signature with types
  • import_statement: How to import the object
  • parameters: List of parameters with types, defaults, and requirements
  • returns: Return type information
  • examples: Code examples extracted from docstrings
  • related: Related functions in the same module

3. Analyze Existing Code

Understand the structure of Python files:

# Get structured analysis
python scripts/code_analyzer.py path/to/file.py

# Get raw AST dump (legacy mode)
python scripts/code_analyzer.py path/to/file.py --raw

The structured output includes:

  • imports and from_imports: All import statements
  • third_party_dependencies: Non-stdlib dependencies
  • functions: Function names, signatures, parameters, decorators
  • classes: Class names, bases, methods, attributes
  • decorators_used: All decorators found in the code

4. Generate Tests and Validate Code

When producing new code or refactoring existing functions, also write unit tests. Run tests locally (e.g., via pytest) and report failures back to the user alongside suggested fixes.

5. Manage the Cache

Documentation lookups are cached for performance:

# View cache statistics
python scripts/cache.py --stats

# Clear the cache
python scripts/cache.py --clear

Scripts Reference

scripts/inspect_env.py

Lists installed packages with comprehensive metadata.

| Flag | Description | |------|-------------| | --simple | Output just [(name, version), ...] format | | --package NAME | Get detailed info for a specific package | | --find-import NAME | Find which package provides an import name | | --env | Show Python environment info only | | --no-cache | Skip cache update |

Output fields (for --package):

  • name: Package name
  • version: Installed version
  • import_names: Actual import names (e.g., ["PIL"] for Pillow)
  • summary: Package description
  • dependencies: List of dependencies
  • location: Installation path
  • main_exports: Main classes/functions exported

scripts/doc_lookup.py

Fetches structured documentation for Python objects.

| Flag | Description | |------|-------------| | --no-cache | Bypass the documentation cache | | --raw | Return raw pydoc text instead of structured JSON |

Output fields (structured mode):

  • name: Object name
  • found: Whether the object was found
  • object_type: function, class, module, builtin
  • import_statement: How to import the object
  • signature: Full signature with types
  • short_description: First line of docstring
  • full_docstring: Complete documentation
  • parameters: List of parameters with types and defaults
  • returns: Return type info
  • examples: Code examples from docstrings
  • raises: Exceptions that may be raised
  • related: Related functions/classes
  • methods: (for classes) List of methods
  • source_file: Path to source code

scripts/code_analyzer.py

Parses Python source code and returns structured information.

| Flag | Description | |------|-------------| | --raw | Output raw AST dump (legacy mode) | | --json | Force JSON output |

Output fields:

  • file_name: Name of analyzed file
  • module_description: Module docstring summary
  • imports / from_imports: Import statements
  • third_party_dependencies: Non-stdlib imports
  • functions: Functions with signatures, parameters, decorators
  • classes: Classes with methods, attributes, bases
  • global_variables: Module-level variables
  • decorators_used: All decorators found
  • summary: Counts of functions, classes, imports

scripts/cache.py

Manages the JSON-based documentation cache.

| Flag | Description | |------|-------------| | --stats | Display cache statistics | | --clear | Reset the entire cache | | --path FILE | Use a custom cache file path |

scripts/health_check.py

Quick health check to verify all skill components are working correctly.

python scripts/health_check.py

Output: Verifies that doc_lookup.py, inspect_env.py, code_analyzer.py, and cache.py are all functioning correctly. Returns exit code 0 on success.

scripts/debug_wrapper.py

Debug wrapper that logs all skill invocations for troubleshooting.

# Look up documentation with logging
python scripts/debug_wrapper.py doc_lookup json.dumps

# Inspect environment with logging
python scripts/debug_wrapper.py inspect_env --find-import PIL

# Analyze code with logging
python scripts/debug_wrapper.py code_analyzer path/to/file.py

Log location: references/skill_usage.log

Each log entry contains:

  • timestamp: When the script was called
  • script: Which script was invoked
  • args: Arguments passed
  • result_preview: First 500 characters of the output

Cache Details

The cache is stored at references/local_docs_index.json and contains:

  • Package tracking: Hash of installed packages to detect environment changes
  • Docstring cache: Up to 500 entries with LFU eviction
  • Statistics: Cache hits, misses, and eviction counts

When packages change (detected via hash), all cached docstrings are invalidated to ensure documentation accuracy.

Example Workflow

# Agent receives: "Help me parse JSON with error handling"

# 1. Check if json is available (it's stdlib, always available)
$ python scripts/doc_lookup.py json.loads
{
  "name": "json.loads",
  "found": true,
  "signature": "loads(s, *, cls=None, ...)",
  "import_statement": "from json import loads",
  "parameters": [...],
  "raises": [{"exception": "JSONDecodeError", "description": "..."}]
}

# 2. Agent can now generate code with proper error handling:
from json import loads, JSONDecodeError

def safe_parse(data: str) -> dict | None:
    try:
        return loads(data)
    except JSONDecodeError as e:
        print(f"Invalid JSON: {e}")
        return None

See the top‑level README.md for more examples.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/python-code-assistant-mmh8qqf1/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/python-code-assistant-mmh8qqf1' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/python-code-assistant-mmh8qqf1/download' --output '.skill-downloads/python-code-assistant-mmh8qqf1/SKILL.md.part' && mv '.skill-downloads/python-code-assistant-mmh8qqf1/SKILL.md.part' '.skill-downloads/python-code-assistant-mmh8qqf1/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Environment declared by the author: Works with any agent runtime that supports the open Agent Skills specification and can execute shell and Python commands (e.g. Claude Code, OpenCode, VS Code Copilot agents). The skill assumes access to the local filesystem and a Python interpreter.

Tools declared by the author (check availability in your agent): Bash Python Read Write

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/python-code-assistant-mmh8qqf1/SKILL.md' && test -s '.skill-downloads/python-code-assistant-mmh8qqf1/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/python-code-assistant' && cp -R '.skill-downloads/python-code-assistant-mmh8qqf1' '.claude/skills/python-code-assistant'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/python-code-assistant-mmh8qqf1'

openskills read 'python-code-assistant-mmh8qqf1'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/python-code-assistant-mmh8qqf1/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills