AI Blocks

Putting the blocks together

This is taking longer than expected.

Try againBrowse the library
AI Blocks · All skills by job · Minds · Mini tools · How it works · From a source · Apps

AI Blocks › Build and ship software

Pure function refactoring planner

Paste a messy function. Get its hidden state listed, a safer version that uses only its inputs, and tests.

Pure function refactoring planner is a free AI skill for the job "Build and ship software". Give the instructions to an AI assistant that supports the required files and tools, then review its output.

Free · No account · Made by AI Blocks · Level: advanced · Thinking: high

What it does

Most hard-to-find bugs come from state that is not what you think it is. A function that reads a global value, a setting or a shared list gives different answers at different times. A function that also changes them leaves traces you cannot see from the call. This skill lists every outside thing the function reads and every change it makes, and writes that list as a comment above it. It then plans a pure version, which depends only on what you hand it and returns results, and a thin layer around it that does the outside work. It writes tests with plain inputs and outputs, states the cost of copying, and flags functions that need a dozen inputs as needing a redesign.

You give it

You get

Use it when

How to use it

  1. Start a chat with the skill. Open it if you added it to your AI, or copy it and paste it in.
  2. Paste the one function you find hardest to trust, plus the code it calls.
  3. Say what it should do and describe the case where it goes wrong.
  4. Read the hidden state list first. Correct anything it missed.
  5. Run the tests against the old function and the new plan, and compare.

More for Build and ship software

Every build and ship software skill