There is no need to introduce code into any tooling to switch namespaces when starting a REPL.
Defining a custom user
namespace has been a long standing approach to managing component lifecycle (start, stop, restart) during development that is not editor, tool or component library dependant, i.e. it works with everything.
Create a dev/user.clj
file in the project that defines a user
namespace. Code in this namespace is loaded during REPL startup, unless it is in comment
forms.
The repl starts in the user
namespace, so functions defined in dev/user.clj
are immediately available without having to switch to a different namespace or use fully qualified names.
Defining functions that manage components in the custom dev/user.clj
user
namespace makes them immediately available in the default namespace used by the REPL.
The added benefit of this approach is cleaner code and a clear separation between development support code and production code.
Libraries such as component repl and integrant repl can be included via a Clojure CLI alias, so they are not adding weight to CI workflow and the resulting deployed uberjar.
The custom user
namespace contains the require statements for component repl (or other develop-time component libraries like Integrant REPL)
Personally I use this approach for launching a range of supporting development tools, regardless of it being Leiningen or Clojure CLI project.
Practicalli Custom REPL Startup details the general approach
Practicalli REPL Reloaded details the specific development tooling I use (portal, hotload, namespace reload, event logging, etc)
Practicalli Project Templates provides production level templates for seancorfiled/deps-new which include a dev/user.clj
custom user
namespace, the practicalli/service
template included Integrant REPL example with aero