# Identify SST command in code

**URL:** <https://discourse.sst.dev/t/identify-sst-command-in-code/2768>\
**Category:** General\
**Created:** [November 25, 2022, 9:16am UTC](https://discourse.sst.dev/t/identify-sst-command-in-code/2768 "2022-11-25T09:16:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jochemd](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jochemd](https://discourse.sst.dev/u/jochemd)\
**Post date:** [November 25, 2022, 9:16am UTC](https://discourse.sst.dev/t/identify-sst-command-in-code/2768/1 "2022-11-25T09:16:45Z")

</div>

I want to conditionally run some code during stack setup depending on whether the command `sst start`, `sst deploy` or `sst remove` was executed. How do I know which command was executed?

---

<div class="post-metadata">

**Author:** ![sebastian3495](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/sebastian3495/32/1545_2.png) [@sebastian3495](https://discourse.sst.dev/u/sebastian3495)\
**Post date:** [November 28, 2022, 10:58am UTC](https://discourse.sst.dev/t/identify-sst-command-in-code/2768/2 "2022-11-28T10:58:20Z")

</div>

Just add the code inside “scripts”: { “start”: … } in package.json? If the code you want to execute is looping until manually killed, you probably want to spawn a parallel thread, and when that is done then run the actual command executed: npx sst start, for instance.

---

<div class="post-metadata">

**Author:** ![jochemd](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jochemd](https://discourse.sst.dev/u/jochemd)\
**Post date:** [November 28, 2022, 12:28pm UTC](https://discourse.sst.dev/t/identify-sst-command-in-code/2768/3 "2022-11-28T12:28:01Z")

</div>

I can just set an environment variable before the `sst start` and detect that and take action based on that in my stack constructor. I was just hoping there would be something built-in.
