DEV Community

Mohammad Mostafa Dastjerdi
Mohammad Mostafa Dastjerdi

Posted on Originally published at mohammadmd1383.github.io

Lint a mods folder before you launch: jdx resources --check

A typo in fabric.mod.json, a mixin config that never made it into the jar, a client entrypoint renamed in code but not in metadata: the loader reports all of these, but only after you have started the game. In a big pack, that start can take a minute or more.

jdx is an open-source CLI and MCP server (Kotlin, Java 21+, Apache-2.0) that answers IDE-style questions about JVM jars without loading or running them. Since v1.8.5 (PR #198, issue #179), jdx resources --check reads the mod metadata inside the jars and reports problems before you launch.

curl -fsSL https://raw.githubusercontent.com/MohammadMD1383/jdx/main/install-release.sh | bash
Enter fullscreen mode Exit fullscreen mode

(Windows: irm https://raw.githubusercontent.com/MohammadMD1383/jdx/main/install-release.ps1 | iex. Existing release installs update with jdx upgrade.)

What it reads

--check looks at fabric.mod.json, quilt.mod.json, META-INF/mods.toml, META-INF/neoforge.mods.toml and mixin configs, plus the mixin configs those files name. It reports:

  • JSON or TOML that doesn't parse, with the line (and the column for JSON).
  • Missing required fields: schemaVersion, id and version for Fabric; modLoader, loaderVersion, license and a [[mods]] entry with a modId for Forge and NeoForge.
  • Entrypoint, mixin and mixin-plugin classes that aren't in any opened jar.
  • Mixin configs named in the metadata that aren't in the same jar.
  • Declared dependencies that no jar in --jars provides. minecraft, java and the loaders themselves are skipped, and so are optional Forge/NeoForge dependencies.

Each finding is an error or a warning.

A small broken pack

To test it, I built three tiny jars:

  • examplemod-1.0.0.jar: its fabric.mod.json names a main entrypoint that exists, a client entrypoint that doesn't, two mixin configs (only one is in the jar) and depends on fabric-api and cloth-config. The mixin config that is in the jar has a trailing comma.
  • cloth-config-15.0.140.jar: only a valid fabric.mod.json with "id": "cloth-config".
  • forgeymod-1.0.0.jar: a META-INF/mods.toml with an unclosed string on displayName, and a required dependency on jei.
jdx resources --check --jars mods --no-jdk
Enter fullscreen mode Exit fullscreen mode
checked 4 metadata files: 4 errors, 1 warning
cloth-config-15.0.140.jar
  fabric.mod.json (fabric.mod.json): ok
examplemod-1.0.0.jar
  examplemod.mixins.json (mixin config): 1 error
    error: malformed JSON: line 8, column 3: unexpected character ']'
  fabric.mod.json (fabric.mod.json): 2 errors, 1 warning
    error: entrypoint 'client' class com.example.client.ExampleModClient is not on the classpath
    error: mixin config 'examplemod.client.mixins.json' is not in this jar
    warning: dependency 'fabric-api' is not provided by any opened jar (add it to --jars, or the game or loader supplies it)
forgeymod-1.0.0.jar
  META-INF/mods.toml (mods.toml): 1 error
    error: malformed TOML: line 8: unterminated string
note: --check reads metadata in place; use --cat to print a file raw. Nothing is downloaded.
Enter fullscreen mode Exit fullscreen mode

Here's how to read it:

  • cloth-config is satisfied because a jar in --jars declares that mod id, so there is no warning for it. fabric-api isn't in the folder, so it gets a warning. minecraft and fabricloader aren't reported at all.
  • The JSON error points at the ] right after the trailing comma, and the TOML error points at the displayName line.
  • A file that doesn't parse can't be checked further. That's why the mixin classes and the jei dependency aren't reported yet.

After fixing the comma and the quote and rebuilding the two jars, the same command goes one level deeper:

checked 4 metadata files: 3 errors, 2 warnings
cloth-config-15.0.140.jar
  fabric.mod.json (fabric.mod.json): ok
examplemod-1.0.0.jar
  examplemod.mixins.json (mixin config): 1 error
    error: mixin class com.example.mixin.ChatHudMixin (in 'mixins') is not on the classpath
  fabric.mod.json (fabric.mod.json): 2 errors, 1 warning
    error: entrypoint 'client' class com.example.client.ExampleModClient is not on the classpath
    error: mixin config 'examplemod.client.mixins.json' is not in this jar
    warning: dependency 'fabric-api' is not provided by any opened jar (add it to --jars, or the game or loader supplies it)
forgeymod-1.0.0.jar
  META-INF/mods.toml (mods.toml): 1 warning
    warning: dependency 'jei' is not provided by any opened jar (add it to --jars, or the game or loader supplies it)
note: --check reads metadata in place; use --cat to print a file raw. Nothing is downloaded.
Enter fullscreen mode Exit fullscreen mode

TitleScreenMixin is in the jar, so only ChatHudMixin is reported. Missing fields look like this, for a neoforge.mods.toml whose [[mods]] entry has no modId:

checked 1 metadata file: 1 error, 0 warnings
neomod-2.0.0.jar
  META-INF/neoforge.mods.toml (neoforge.mods.toml): 1 error
    error: [[mods]] #1 is missing 'modId'
note: --check reads metadata in place; use --cat to print a file raw. Nothing is downloaded.
Enter fullscreen mode Exit fullscreen mode

Narrowing it down

The usual resources filters work. --in limits the check to one jar, and the other jars still count as providers:

jdx resources --check --in 'examplemod*' --jars mods --no-jdk
Enter fullscreen mode Exit fullscreen mode

That prints checked 2 metadata files: 3 errors, 1 warning with just the examplemod-1.0.0.jar section. A pattern works too: jdx resources --check fabric.mod.json --jars mods --no-jdk checks every fabric.mod.json and the mixin configs they name. --limit caps how many files are listed.

In a script or CI

Findings don't change the exit code. The command exits 0 when at least one metadata file was checked, even with errors, and 1 when nothing matched:

$ jdx resources --check 'nothing-here.toml' --jars mods --no-jdk
not found: nothing-here.toml
no mod metadata matching 'nothing-here.toml'
Enter fullscreen mode Exit fullscreen mode

(exit 1). --check together with --cat is a usage error (exit 3).

To fail a build, use --json, which carries every finding with its severity:

jdx resources --check --jars mods --no-jdk --json \
  | jq -r '.result.files[] | .artifact as $a | .findings[] | select(.severity=="error") | "\($a): \(.message)"'
Enter fullscreen mode Exit fullscreen mode
examplemod-1.0.0.jar: mixin class com.example.mixin.ChatHudMixin (in 'mixins') is not on the classpath
examplemod-1.0.0.jar: entrypoint 'client' class com.example.client.ExampleModClient is not on the classpath
examplemod-1.0.0.jar: mixin config 'examplemod.client.mixins.json' is not in this jar
Enter fullscreen mode Exit fullscreen mode

The summary also includes .result.errors and .result.warnings counts, so jq -e '.result.errors == 0' makes a one-line gate.

Caveats

  • No remapping. Class checks look for the names the jar stores. For anything that refers to game classes, pass the Loom-mapped Minecraft jar with --jars, in the same namespace as the mods.
  • Version ranges aren't checked. "cloth-config": ">=15" passes if any jar declares cloth-config, whatever its version.
  • No load order. jdx doesn't simulate the loader. It doesn't resolve which mod wins, doesn't detect conflicts between mods and doesn't apply mixins.
  • Nothing is downloaded and no class is loaded. A missing dependency is a warning. jdx never fetches it, and the game or loader may still supply it.
  • Exit code. Findings don't change the exit code (see above).
  • Nested jars. In v1.8.5, a dependency that a mod only bundles as jar-in-jar can still show up as "not provided". The fix (PR #203) is on main and will be in the next release.

From an agent

The MCP tool jdx_resources takes check, so after jdx setup --agent claude-code an agent can run the same check on a mods folder and read the findings as JSON.

The repo is at https://github.com/MohammadMD1383/jdx. The modpack guide covers the other questions, like which mod logs a message, ships a duplicate class or mixes into a class: https://mohammadmd1383.github.io/jdx/docs/minecraft-modpack/

Top comments (0)