{"slug": "boxing-in-the-llm-rest-assured-to-postman-with-claude-code", "title": "Boxing in the LLM: REST Assured to Postman with Claude Code", "summary": "Postman built a REST Assured converter that converts Java API test suites into Postman Collections by running Claude Code inside deterministic scaffolding, with a shell `for` loop deciding what to convert and a worker handling one Java test class at a time. The production converter schedules work with `p-map` at a concurrency of 6, gives each unit three attempts, and enforces a 30-minute pipeline timeout; a unit that fails all three attempts lands in a failed list and the run continues. The design deliberately places the LLM at the leaves of the call tree rather than the root, with no coordinator agent, because handing an entire project to a model in one prompt produces invented cross-class references.", "body_md": "# Boxing in the LLM: REST Assured to Postman with Claude Code\n\nMigrating a mature Java API test suite into Postman sounds like a job for an LLM until you try it. A single REST Assured project can carry hundreds of `@Test` methods across dozens of classes, a `BaseTest` that sets the base URI in a `@BeforeSuite`, parameterized data providers, a few WireMock stubs, and a TestNG suite XML that quietly decides which classes run. Hand all of it to a model in one prompt and you get creative fiction. Hand it one class at a time, inside boring deterministic scaffolding, and you get correctness.\n\nThat’s the architecture we landed on when we built Postman’s REST Assured converter, and it carries over to a workflow you can run on your own machine. In this post you’ll convert a REST Assured project to a Postman Collection with Claude Code and the [Postman plugin](https://learning.postman.com/docs/postman-plugin/skills). A shell `for` loop decides what to convert and how many pieces there are. A boxed-in worker converts one test class at a time. The plugin’s skills supply the collection file format, run the result, and gate it in CI. The most reliable agent in the system is the `for` loop.\n\n## Box in the model\n\nEvery decision downstream flows from one choice: what counts as a unit of work the model is allowed to reason about? We picked one Java test class. A method is too little context, because data providers and helper methods live at the class level. A whole project is too much, and the model starts inventing cross-class references. Once you commit to that boundary, the rest of the design follows:\n\n| Job | Who does it | Why | \n|---|---|---|\n| Find the test classes | A regex | JUnit 5 and TestNG markers are well defined, so there’s no reason to spend tokens looking for them | \n| Resolve shared config such as the base URI | One model call, once | Every worker reuses the answer, so you don’t get N different names for the same variable | \n| Fan out across classes | A `for` loop with retries | When a class fails, it fails alone | \n| Translate one class | A worker with read-only tools | This is the part that needs judgment | \n| Write files and assemble the collection | Code | No model call decides where a file goes | \n| Check the result | The Postman CLI | Lint checks structure and a run checks behavior | \n\nIn the production converter, the scheduling is [`p-map`](https://github.com/sindresorhus/p-map) with a concurrency of 6, each unit gets three attempts, and the whole pipeline has a 30-minute timeout. A unit that fails all three attempts lands in a failed list and the run keeps going. There is no coordinator agent: no orchestrator LLM watching the run, no planner picking the next unit. The agent is a function that the loop calls, so the LLM lives at the leaves of the call tree, not the root.\n\n## What you need\n\n- [Claude Code](https://code.claude.com/docs/en/headless) with the`claude` command on your path\n- The Postman CLI (the plugin’s `cli-install` skill can install it if it’s missing)\n- `jq` and a Unix shell\n- A REST Assured project with JUnit 5 or TestNG tests\n\n## Install the Postman plugin\n\nOne command installs the plugin into each supported agent it detects, including Claude Code:\n\n```\nnpx @postman/postman-plugin\n```\n\nThe plugin gives Claude skills for API engineering. Each skill holds instructions the agent reads for a task. This workflow touches four of them: `collection-schema-v3` for the collection file format, `api-testing` for running assertions, `api-mocking` for stubs, and `ci-integration` for the pull request gate. Linting and running a collection locally don’t require you to sign in to Postman. You only need to sign in when you publish to a workspace.\n\n## Step 1: Discover test classes with grep\n\nBefore any model runs, a discovery pass walks the project with plain tools. The marker count it records becomes the coverage target for each class. Create `scripts/discover.sh`:\n\n``` bash\n#!/usr/bin/env bash\n# Step 1: find every test class and count its test markers. No model involved.\nset -euo pipefail\nMARKER='@([A-Za-z0-9_.]*\\.)?(Test|ParameterizedTest|RepeatedTest|TestFactory|TestTemplate)([^A-Za-z0-9_]|$)'\n\ngrep -rlE \"$MARKER\" src/test/java | sort | while read -r file; do\n  printf '%s\\t%s\\n' \"$file\" \"$(grep -cE \"$MARKER\" \"$file\")\"\ndone > units.tsv\n\ncat units.tsv\n```\n\nOn the demo project, which has a `BaseTest` plus `UsersTest` and `PostsTest`, the output looks like this:\n\n```\nsrc/test/java/com/example/PostsTest.java    3\nsrc/test/java/com/example/UsersTest.java    2\n```\n\n`BaseTest` has no test markers, so it isn’t a unit. It’s context the workers will read. Over-inclusion is fine at this stage. A class with no HTTP calls comes back with an empty list, while a class that never got enumerated is a bug you may not notice for months.\n\n## Step 2: Resolve shared configuration once\n\nMost REST Assured projects build a shared `RequestSpecBuilder` in a base class. If every worker rediscovered it independently, you’d get a different guess at the variable name from each one. So a single resolver call runs first, with a prompt that is aggressively narrow. Save it as `prompts/resolver.md`:\n\n```\nResolve the CROSS-CUTTING configuration shared across all tests in this Java API-test project.\nDo this ONCE: every test class will reuse your output. You are NOT converting tests here.\n\nLook for a base class or @BeforeSuite/@BeforeClass block that sets the base URI, shared\nheaders, content type, or authentication. Use the read, glob, and grep tools.\n\nReturn ONLY a single JSON object, with no prose and no code fence, in exactly this shape:\n{\"variables\":[{\"key\":\"baseUrl\",\"value\":\"https://...\"}],\"brief\":\"two or three sentences about shared setup the converters need to know\"}\n```\n\nThen call it from `scripts/resolve.sh`. The `--allowedTools` flag is the box: this call can read files and nothing else. Redirecting stdin from `/dev/null` keeps `claude -p` from waiting on a pipe.\n\n``` bash\n#!/usr/bin/env bash\n# Step 2: one model call that resolves shared configuration.\nset -euo pipefail\n\nclaude -p \"$(cat prompts/resolver.md)\" \\\n  --allowedTools \"Read,Glob,Grep\" \\\n  --output-format json < /dev/null \\\n  | jq -r '.result' \\\n  | sed -e '/^```/d' > resolved.json\n\njq -e '.variables and .brief' resolved.json > /dev/null\ncat resolved.json\n```\n\nThe last `jq -e` line is a deterministic check on a probabilistic step. If the model returns anything other than the shape you asked for, the script stops. On the demo project, the resolver returns this:\n\n```\n{\n  \"variables\": [\n    { \"key\": \"baseUrl\", \"value\": \"https://jsonplaceholder.typicode.com\" }\n  ],\n  \"brief\": \"BaseTest.setupSpec() (@BeforeSuite) sets a global RestAssured request spec with base URI https://jsonplaceholder.typicode.com and Content-Type application/json. There is no authentication and there are no other shared headers or base path.\"\n}\n```\n\nThe worker never has to guess what to name `baseUrl`, because it was told.\n\n## Step 3: Convert one class at a time with a for loop\n\nThe worker prompt is explicit about its boundary. It converts exactly one class, it can’t write files, and it has to return JSON. Save it as `prompts/worker.md`:\n\n```\nYou convert exactly ONE Java REST Assured test class into Postman v3 request files.\nYou have read-only tools (read, glob, grep) scoped to this project. You cannot write\nfiles or run commands. Read the class named at the end of this prompt, and follow\nbase classes, helpers, and data providers it depends on.\n\nUse the collection-schema-v3 skill for the exact shape of *.request.yaml files.\n\nRules:\n- Write one request per @Test method. If a data provider changes the request, write one request per row.\n- Use {{baseUrl}} for the base URI. Never hardcode the host. Reuse the variable names from the shared setup below.\n- Put assertions in an afterResponse script, using pm.test and pm.expect.\n- Translate REST Assured and Hamcrest like this:\n\n  .statusCode(n)                  -> pm.response.to.have.status(n)\n  .body(\"json.path\", matcher)     -> assert on pm.response.json() at that path\n  .time(lessThan(ms))             -> pm.expect(pm.response.responseTime).to.be.below(ms)\n  .header(k, v)                   -> pm.expect(pm.response.headers.get(k)).to.eql(v)\n  equalTo(x) / is(x)              -> .to.eql(x)\n  hasItem(x) / containsString(s)  -> .to.include(x)\n  greaterThan(n) / lessThan(n)    -> .to.be.above(n) / .to.be.below(n)\n  notNullValue() / nullValue()    -> .to.exist / .to.not.exist\n  hasSize(n)                      -> .to.have.lengthOf(n)\n\nReturn ONLY a JSON object, with no prose and no code fence, in exactly this shape:\n{\"requests\":[{\"file\":\"get-user-by-id.request.yaml\",\"yaml\":\"<the full file contents>\"}]}\n```\n\nThis is where the model earns its keep. It maps the [REST Assured](https://rest-assured.io/) fluent DSL and [Hamcrest matchers](https://hamcrest.org/JavaHamcrest/tutorial) onto `pm.expect` chains, which is a translation problem a model handles well. The prompt names the `collection-schema-v3` skill so the worker gets the exact file shape instead of recalling it. In a streamed run of the demo, the worker reads the class, calls the skill, and reads the skill’s files before it answers.\n\nNow the loop itself, `scripts/convert.sh`. It reads `units.tsv`, gives each class three attempts, checks that the request count meets the marker count, and only then writes files:\n\n``` bash\n#!/usr/bin/env bash\n# Step 3: the for loop. One worker per test class, three attempts each.\nset -uo pipefail\nOUT=postman/collections/rest-assured\nmkdir -p \"$OUT/.resources\"; : > failed-units.txt\n\n# The collection definition comes from the resolver output. No model involved.\njq -r '\"$kind: collection\\nname: REST Assured tests\\nvariables:\" +\n  ([.variables[] | \"\\n  - key: \\(.key)\\n    value: \\(.value | @json)\"] | join(\"\"))' \\\n  resolved.json > \"$OUT/.resources/definition.yaml\"\n\nwhile IFS=$'\\t' read -r unit expected; do\n  name=$(basename \"$unit\" .java)\n  for attempt in 1 2 3; do\n    prompt=\"$(cat prompts/worker.md)\n\nShared setup: $(cat resolved.json)\nUnit to convert: $unit\"\n\n    claude -p \"$prompt\" \\\n      --allowedTools \"Read,Glob,Grep,Skill\" \\\n      --output-format json < /dev/null > \"run-$name.json\" 2> /dev/null || continue\n    jq -r '.result' \"run-$name.json\" | sed -e '/^```/d' > \"items-$name.json\"\n\n    returned=$(jq -e '.requests | length' \"items-$name.json\" 2> /dev/null) || continue\n    if [ \"$returned\" -lt \"$expected\" ]; then\n      echo \"$name: attempt $attempt returned $returned of $expected, retrying\"; continue\n    fi\n\n    mkdir -p \"$OUT/$name\"\n    jq -c '.requests[]' \"items-$name.json\" | while read -r req; do\n      file=$(jq -r '.file' <<< \"$req\" | tr -cd 'A-Za-z0-9._-')\n      jq -r '.yaml' <<< \"$req\" > \"$OUT/$name/$file\"\n    done\n    echo \"$name: $returned/$expected requests ($(jq -r '.num_turns' \"run-$name.json\") turns, \\$$(jq -r '.total_cost_usd' \"run-$name.json\"))\"\n    continue 2\n  done\n  echo \"$name\" >> failed-units.txt\n  echo \"$name: failed after 3 attempts\"\ndone < units.tsv\n```\n\nRun it:\n\n```\nchmod +x scripts/*.sh\n./scripts/discover.sh && ./scripts/resolve.sh && ./scripts/convert.sh\n```\n\nOn the demo project, each class converts on the first attempt:\n\n```\nPostsTest: 3/3 requests (5 turns, $0.308115)\nUsersTest: 2/2 requests (5 turns, $0.309468)\n```\n\nYour turn counts and costs depend on your model and your project. The shape of the result matters more: the model never touched the file system. It returned JSON, and the loop validated it, counted it, and placed each file. A prompt-injected comment in a test file can’t make the worker write anything or run anything, because the worker has no tool that does either.\n\n## What the worker wrote\n\nHere’s `UsersTest.getUserById` next to the request file the worker returned for it:\n\n```\n@Test\npublic void getUserById() {\n    given()\n    .when()\n        .get(\"/users/1\")\n    .then()\n        .statusCode(200)\n        .body(\"id\", equalTo(1))\n        .body(\"name\", equalTo(\"Leanne Graham\"))\n        .body(\"username\", equalTo(\"Bret\"))\n        .body(\"email\", equalTo(\"[email protected]\"));\n}\n$kind: http-request\nname: getUserById\nmethod: GET\nurl: '{{baseUrl}}/users/1'\norder: 1000\nheaders:\n  - key: Content-Type\n    value: application/json\nscripts:\n  - type: afterResponse\n    language: text/javascript\n    code: |-\n      pm.test('status code is 200', () => {\n        pm.response.to.have.status(200);\n      });\n\n      pm.test('user fields match', () => {\n        const body = pm.response.json();\n        pm.expect(body.id).to.eql(1);\n        pm.expect(body.name).to.eql('Leanne Graham');\n        pm.expect(body.username).to.eql('Bret');\n        pm.expect(body.email).to.eql('[email protected]');\n      });\n```\n\nThe base URI is now the `{{baseUrl}}` collection variable, the Hamcrest matchers are `pm.expect` chains, and the test names are readable. Query parameters came through too. `PostsTest.getPostsByUser` has a `userId` parameter, and the worker recorded it in both the URL and the `queryParams` list, which is what the v3 format requires.\n\n## Step 4: Lint and run the collection\n\nThe converter’s job ends when files exist. The Postman CLI decides whether they’re any good. Lint checks structure:\n\n```\npostman collection lint postman/collections/rest-assured\nNo issues found.\nScanned: 5 | Errors: 0 | Warnings: 0 | 5ms\n```\n\nThen run the collection, which is the `api-testing` skill’s core move: reuse the saved requests and assertions as regression checks.\n\n```\npostman collection run postman/collections/rest-assured\nFolder UsersTest\nSub-folder getUserById\n\n  GET https://jsonplaceholder.typicode.com/users/1 [200 OK, 1.25 KB, 55 ms]\n  Pass  status code is 200\n  Pass  user fields match\n\n...\n\n|              iterations |                   1 |                   0 |\n|                requests |                   5 |                   0 |\n|            test-scripts |                   5 |                   0 |\n|              assertions |                  12 |                   0 |\n```\n\nFive requests ran and all 12 assertions passed. Lint and a green run are two different guarantees. Lint says Postman can read the files. A run says the converted checks hold against the API. Neither says the converted checks match the original intent, so compare the counts. The demo’s Java tests contain 15 REST Assured checks, and they became 12 `pm.test` blocks, because the worker grouped the four field checks in `getUserById` into one test. That’s a reasonable choice, and it’s also the kind of thing to skim before you trust a migration.\n\n## Handle WireMock stubs with api-mocking\n\nA project with WireMock stubs has a second kind of unit, and the demo scripts above don’t cover it. In the production converter, a class with no test markers but real `stubFor` blocks routes to a mock-specific prompt. You can add the same branch to this loop with a second marker pattern in `discover.sh` and a second worker prompt. Each stub becomes a request with a saved response example in the `*.example.yaml` format the `collection-schema-v3` skill documents. From there the `api-mocking` skill takes over. `postman mock generate` builds a mock from a collection’s documented responses, and `postman mock run` serves it locally without a sign-in. A suite that needed a local WireMock process can point at that mock instead.\n\nOne caveat from the skill’s own guidance: a generated mock replays documented responses. A `POST` and a later `GET` share no state, so put the error cases your callers handle, such as the unknown-ID 404, into the examples. Read the [mock command reference](https://learning.postman.com/docs/postman-cli/postman-cli-mock) before you rely on a mock for behavior it can’t model.\n\n## Gate the collection in CI\n\nOnce the converted tests pass locally, the `ci-integration` skill’s job is to make a pull request carry them. Pick one gate per guarantee so a failed build tells you whether structure or behavior broke. This workflow lints first, then runs:\n\n```\nname: API checks\n\non:\n  pull_request:\n    paths:\n      - 'postman/**'\n\njobs:\n  collection-checks:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n\n      - name: Install the Postman CLI\n        run: curl -o- \"https://dl-cli.pstmn.io/install/linux64.sh\" | sh\n\n      - name: Lint the collection\n        run: postman collection lint postman/collections/rest-assured -f error\n\n      - name: Run the collection\n        run: postman collection run postman/collections/rest-assured -r junit,html\n```\n\nThe demo collection calls a public API, so it runs as is. For a real suite, point the job at a mock or a staging environment you’re willing to write to, because a collection run sends real requests. A local-only gate like this one needs no API key. Add `postman login` with a secret from your CI store when you want run results published to a workspace. See [Run the Postman CLI in GitHub Actions](https://learning.postman.com/docs/postman-cli/postman-cli-github-actions) for the details.\n\n## Things to watch for\n\n- Coverage is a count, not a guarantee. The marker count catches “the model got bored and stopped.” It can’t catch a request that exists but asserts the wrong thing.\n- Check `failed-units.txt` after every run. A failed class is named there. The collection is smaller than the project it came from but still valid, so the failure is hard to notice if you only look at the green run.\n- Treat the model’s output as untrusted input. Validate the JSON shape with `jq` , sanitize file names, and write files from the loop, never from the worker.\n- Keep the shell away from the worker. The read-only tool list is what makes the loop safe to point at a large codebase.\n- Don’t drop classes because a TestNG suite file omits them. Suite files go stale in real projects, so use them to report orphan classes only.\n\n## The generalizable idea\n\nThe REST Assured specifics don’t matter as much as the questions behind them. What is the smallest unit of work the model can reason about correctly on its own? Which parts of the problem are deterministic enough that code can own them outright? Where does the model earn its keep, and where are you paying token cost for a regex?\n\nThe answers reshape the architecture. Discovery becomes a regex pass. Shared configuration becomes a one-shot call. Fan-out becomes a `for` loop. Assembly becomes code that writes files. What’s left in the middle is a small, boxed-in agent doing a translation it’s good at.\n\nThe most useful thing we did was stop trying to make the agent smarter and start making the code around it dumber. The `for` loop doesn’t have opinions about REST Assured, doesn’t misremember which classes it already converted, and doesn’t run out of context. It keeps calling the worker until the units are gone.\n\n## Try it yourself\n\nCopy the three scripts and two prompts from this post into the root of your Maven or Gradle project, then work through it in this order:\n\n1. Run `npx @postman/postman-plugin` to install the plugin.\n2. Run `./scripts/discover.sh` and check that`units.tsv` lists the classes you expect.\n3. Run `./scripts/resolve.sh` and read`resolved.json` . If the variable name or base URI is wrong, fix the prompt before you convert anything.\n4. Trim `units.tsv` to one or two classes and run`./scripts/convert.sh` .\n5. Run `postman collection lint` and`postman collection run` on the output, then compare the REST Assured check count with the`pm.test` count.\n6. Restore the full `units.tsv` , run the loop again, and open`failed-units.txt` .\n\nThen change one thing and watch what happens. Add a data provider to a test and see whether the worker writes one request per row. Remove `Skill` from `--allowedTools` and compare the generated files. Add a class with no HTTP calls and confirm it returns an empty list.", "url": "https://wpnews.pro/news/boxing-in-the-llm-rest-assured-to-postman-with-claude-code", "canonical_source": "https://blog.postman.com/boxing-in-the-llm-rest-assured-to-postman-with-claude-code/", "published_at": "2026-12-02 16:00:00+00:00", "updated_at": "2026-12-02 16:18:22.216843+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "large-language-models"], "entities": ["Postman", "Claude Code", "REST Assured", "p-map", "TestNG", "JUnit 5", "WireMock", "Postman CLI"], "also_reported_by": [], "takeaway": "Scope each LLM conversion unit to one Java test class rather than a method or a whole project, fan out with a `for` loop using three retries per unit and a 30-minute timeout, and let code—not the model—decide file placement and collection assembly.", "recommendation": {"advice": "Bound each agent call to one test class with read-only tools, fan out via a `for` loop with three retries per unit, and keep file writing and assembly in deterministic code rather than model calls.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/boxing-in-the-llm-rest-assured-to-postman-with-claude-code", "markdown": "https://wpnews.pro/news/boxing-in-the-llm-rest-assured-to-postman-with-claude-code.md", "text": "https://wpnews.pro/news/boxing-in-the-llm-rest-assured-to-postman-with-claude-code.txt", "jsonld": "https://wpnews.pro/news/boxing-in-the-llm-rest-assured-to-postman-with-claude-code.jsonld"}}