Automatically cleaning up unused server actions

As the project grows, it becomes messier…
The best would be to keep things clean, but alas, not always possible.

I’m thinking to write a script to find unused server actions and delete them.

But I’d like some input please!

  1. What should I write the script in? (Thinking python, never worked with it tho)
  2. We can detect unused server actions if:
    A: They’re not included in any page (As server connect)
    B: They’re not included as any library action
    C: They’re not marked as a server action that is meant to be ran directly (we have a bunch of dev tools like that that we just run in the browser)

Do you think this is complete?

3 Likes

You planning node only or all server platforms. node will need a check on schedulers also

Node. good point :slight_smile:

I will just share the script here and then others can adjust it to their needs

-Maybe, an exclude list per target, dev, stag and prod., . Because some server actions works in test enviroment only, they are not upload in prod.
-Some server actions are used only as server side data in Frontend, so, not necessary are included as server connect in Frontend.

Great idea! Look forward to it. One thing I would request is that it produce a list that the server connects can be (de)selected from prior to deleting. I have a few about that I use for testing various things that aren’t connected to anything else so wouldn’t want those to auto delete!

1 Like

Great idea! Another place to check for any server actions that are in use will be the Server Connect Routes.

1 Like

Well this project was put into the 'this was too ambitious, I don't have time for this' box.

But with Claude code being so amazing: 🧹 New: Wappler Cleanup Tool - Keep Your Projects Clean!

Here you go :slight_smile: