Skip to main content

script-chain-walk

Trace cross-file script call chains. Point it at a directory of shell and Python scripts and it builds the full call graph — a.sh calls b.py calls c.sh — then flags broken chains (calls to files that don't exist) and call cycles. Standard library only, zero dependencies.

Install

pip install script-chain-walk

Usage

# Text tree of every call chain in ./scripts
walk ./scripts

# Machine-readable output
walk ./scripts --format json

# Only the chain starting from one entry point
walk ./scripts --entry deploy.sh

# CI / guardrail mode: exit 1 if any broken chain or cycle is found
walk ./scripts --check

Example output:

deploy.sh
|-- migrate.py  (line 3, exec)
|   `-- seed.sh  (line 12, exec)
`-- notify.sh  (line 5, exec)

========================================
scripts: 4   edges: 3   broken: 1   cycles: 0

BROKEN CHAINS (call target not found):
  notify.sh:8 -> ./cleanup.sh (exec, missing)

What it detects:

  • Shell: bash foo.sh, ./foo.sh, sh -x foo.sh, source lib.sh, . lib.sh, python3 bar.py, exec ./foo.sh (comments ignored, line continuations joined).
  • Python (parsed with the real AST, not regex): subprocess.run(...), os.system(...) / os.popen(...), os.execv(...) and friends, exec(open("other.py").read()), runpy.run_path("other.py").
  • Resolution: relative to the caller first, then a unique basename match anywhere in the tree; absolute paths honored too. Unresolvable targets are reported as broken (or ambiguous when several files share the name).

Differentiation

Static analyzers like ShellCheck or Pylint look at one file at a time — they will happily pass a script that calls ./deploy.sh when deploy.sh was deleted last month. script-chain-walk is the call map across files: which script triggers which, where the chain dead-ends, and where it loops back on itself.

If you run coding agents, this is the missing piece of script-behavior auditing: before trusting an agent's shell output, walk --check its script directory and see the actual invocation graph — dead scripts an agent keeps "calling", and accidental recursion — instead of reading each file by hand.

How it works

  1. Recursively finds scripts (by extension or shebang).
  2. Extracts calls: shell lines via quote-aware tokenizing, Python via ast.
  3. Resolves every target against the directory tree.
  4. DFS over the graph for cycles; in-degree zero for entry points.
  5. Renders a text tree or JSON; --check turns findings into an exit code.

License

MIT. See LICENSE.

Metadata

Release files for script-chain-walk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for script-chain-walk 0.1.0
File Size Uploaded Provenance
script_chain_walk-0.1.0.tar.gz 11.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for script-chain-walk 0.1.0
File Interpreter ABI Platform
script_chain_walk-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.4 kB

Release files / script_chain_walk-0.1.0.tar.gz

Download URL script_chain_walk-0.1.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dd3e5b47fd43ff6a155c83bfa049644a302c62cdd8820564eefd0c8d5d20947e
BLAKE2b-256 checksum
How to use checksums
60cd65641eda7d1f56abbc6eb3ad3f8ac0c46f94511a69070fd08414075d7854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / script_chain_walk-0.1.0-py3-none-any.whl

Download URL script_chain_walk-0.1.0-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8d376139713b32a10648a5f4713bde74d06971404a22e2832d68c7830a530d6
BLAKE2b-256 checksum
How to use checksums
45f808c1c572a2f252598bd066de095548e0f40f9115ab4f46b270399b70209d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for script-chain-walk 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page