A Clojure(Script) library that saves and restores local runtime environments at the REPL for easier debugging and exploration.
Scope-capture is a Clojure and ClojureScript library that helps developers save and restore the local runtime environment of their code at the REPL. It solves the tedious problem of manually recreating variable contexts during debugging by capturing snapshots when code executes, allowing instant replay for investigation.
Clojure and ClojureScript developers who use REPL-driven workflows, particularly those debugging complex functions, onboarding to new projects, or exploring unfamiliar codebases.
Developers choose scope-capture because it automates environment recreation, reducing manual effort and errors. Its unique selling point is enabling context restoration after just one code execution, making debugging more immediate and accessible.
Project your Clojure(Script) REPL into the same context as your code when it ran
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
sc.api/spy and sc.api/brk macros automatically save local environments during code execution, eliminating manual variable recreation as shown in the basic usage example.
Offers multiple restoration methods: sc.api/letsc for local bindings and sc.api/defsc for global vars, catering to different REPL workflows and editor integrations.
sc.api/brk pauses execution and allows resumption from the REPL with override values via sc.api/loose-with!, enabling step-through debugging without external tools.
Lowers the barrier for new developers by enabling mechanical environment recreation without deep project knowledge, as emphasized in the rationale section.
Works with both Clojure and ClojureScript, including browser-connected REPLs, though with specific caveats for ClojureScript usage.
Requires explicit code site IDs in ClojureScript (e.g., sc.api/letsc [7 -3]), which is non-intuitive and error-prone, as admitted in the README's caveats.
Must be added to user profiles (e.g., ~/.lein/profiles.clj) rather than project dependencies, complicating setup and team-wide adoption compared to simple dependency management.
sc.api/defsc overwrites global vars with captured locals, risking conflicts with existing definitions and making it unsuitable for shared or production-like environments.
Dynamic vars require manual declaration for capture (e.g., :sc/dynamic-vars option), adding boilerplate and potential for missed bindings in complex applications.