src/main/skills/gradle/SKILL.md
Provides authoritative guidance for ALL Gradle operations: executing builds, running tests with surgical filtering, introspecting project structure, creating modules, and diagnosing failures; ALWAYS use instead of raw shell `./gradlew` for build execution, test runs, task introspection, module creation, performance audits, and documentation research. Do NOT use for dependency graph auditing/updates (use `managing_gradle_dependencies`) or dependency/plugin/Gradle source exploration (use `exploring_dependency_sources`).
npx skillsauth add rnett/gradle-mcp gradleInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Executes builds, runs tests with high-precision filtering, introspects project structure, and diagnoses failures using managed orchestration and structured diagnostics.
gradle tool instead of ./gradlew via shell.projectRoot.captureTaskOutput when you need the isolated output of a specific task (e.g., help, projects, tasks, properties, dependencies).query_build for all diagnostics. It is more token-efficient than reading raw console logs and provides structured access to failures, problems, and per-test output.query_build with kind="TESTS" and query="FullTestName" to access full test output and stack traces.taskPath or captureTaskOutput to investigate specific test failures; these provide the overall task log which is often truncated and lacks per-test isolation. Per-test output (via query) is authoritative and includes
full stack traces.--rerun-tasks unless investigating project-wide cache-specific corruption; prefer --rerun for individual tasks.help --task <name> command for authoritative documentation.stopBuildId to release resources when finished..kts) unless the project explicitly uses Groovy.tasks.register<MyTask>("myTask")) instead of eager APIs (e.g., tasks.create<MyTask>("myTask")) to maintain configuration performance.libs.versions.toml) for dependency management when present.gradle_docs for authoritative documentation lookup instead of generic web searches.?.url?.toString()) and provide fallback values when accessing ArtifactRepository URLs in Gradle init scripts or plugins to prevent NullPointerException.:properties --property <name> for surgical property extraction.Gradle uses two ways to identify tasks from the command line. Precision prevents running redundant tasks in multi-project builds.
Providing a task name without a leading colon (e.g., test, build) acts as a selector. Gradle executes that task in every project (root and all subprojects) that contains a task with that name.
gradle(commandLine=["test"]) -> Executes test in all projects.Providing a task path with a leading colon (e.g., :test, :app:test) targets a single specific project.
gradle(commandLine=[":test"]) -> Root project ONLY.gradle(commandLine=[":app:test"]) -> ':app' subproject ONLY.--tests)The --tests flag supports powerful, high-precision filtering:
--tests com.example.MyTest--tests com.example.MyTest.myTestMethod--tests com.example.MyTest.test* (All methods starting with 'test')--tests com.example.service.* (All tests in the 'service' package)--tests *IntegrationTest (All classes ending in 'IntegrationTest')--tests com.example.Test? (Matches Test1, TestA, etc.)gradle(commandLine=["test", "--tests", "ClassA", "--tests", "ClassB"])Patterns match against the fully qualified name of the test class or method.
background: true ONLY for tasks that must remain active (e.g., bootRun, continuous builds) or when you intentionally intend to perform independent research while the build proceeds.gradle tool uses progressive disclosure to provide concise summaries and structured results, keeping session history clean.captureTaskOutput UsageUse captureTaskOutput when you need clean, isolated output from a specific task without Gradle's general console noise. This is ideal for introspection tasks:
captureTaskOutput: ":projects" - Clean project listcaptureTaskOutput: ":app:tasks" - Task list for a specific projectcaptureTaskOutput: ":help" - Documentation for a specific taskcaptureTaskOutput: ":properties" - Single property extractioncaptureTaskOutput: ":app:dependencyInsight" - Dependency resolution pathgradle_docs Tag SyntaxUse gradle_docs for authoritative documentation. Always scope with tags:
| Tag | Section |
|----------------------|----------------------------------------------------|
| tag:userguide | Official Gradle User Guide |
| tag:dsl | Gradle DSL Reference (Groovy and Kotlin DSL) |
| tag:javadoc | Gradle Java API Reference |
| tag:samples | Official Gradle samples and examples |
| tag:release-notes | Version-specific release insights |
| tag:best-practices | Official best practices and performance guidelines |
Explore sections with path=".". Search scoped with tag:<section> <term>.
register over create (Lazy APIs): Use tasks.register<MyTask>("myTask") to avoid eager task configuration.tasks.test { ... } or tasks.named<Test>("test") { ... } over tasks.getByName("test").Property<T> and Provider<T> APIs for late binding and configuration cache compatibility.gradle/libs.versions.toml.allprojects/subprojects: These blocks create tight coupling; use convention plugins and apply them selectively.Project object inside task actions.@Input, @OutputFiles, @Internal, etc.build-logic.query_build() without arguments to view the build dashboard and ensure no orphaned background builds are consuming system resources.invocationArguments: { envSource: "SHELL" } if Gradle cannot find expected env vars (e.g., JAVA_HOME).For comprehensive guidance on using query_build and wait_build for diagnostics, including JSON examples for every inspection mode (DASHBOARD, SUMMARY, FAILURES, PROBLEMS, TASKS, TESTS, CONSOLE, PROGRESS), refer
to: query_build Diagnostics Reference.
["clean", "build"]).gradle(commandLine=["...", "..."]).query_build with the buildId for deeper diagnostics via query_build Diagnostics Reference.:app) and the test filter (e.g., com.example.MyTestClass*).gradle(commandLine=[":app:test", "--tests", "com.example.MyTest"]).query_build to get detailed test output.background: true to receive a BuildId.wait_build(buildId=ID, timeout=..., waitFor=...) to block until a specific state or log pattern is reached.query_build() (no arguments) to manage active jobs in the dashboard.gradle(stopBuildId=ID) when finished.gradle(commandLine=[":projects"], captureTaskOutput=":projects") to map the multi-project hierarchy.gradle(commandLine=[":app:tasks", "--all"], captureTaskOutput=":app:tasks") to discover runnable tasks.gradle(commandLine=[":help", "--task", "test"], captureTaskOutput=":help") for task-specific documentation.gradle(commandLine=[":properties", "--property", "version"], captureTaskOutput=":properties") for surgical property extraction.gradle(commandLine=[":app:dependencyInsight", "--dependency", "slf4j-api", "--configuration", "compileClasspath"], captureTaskOutput=":app:dependencyInsight").gradle(commandLine=[":projects"], captureTaskOutput=":projects") to find the correct parent path.New-Item -ItemType Directory -Force -Path "<module-name>/src/main/kotlin".settings.gradle.kts: Append include(":<module-name>").build.gradle.kts with idiomatic patterns (apply convention plugins, set up standard configuration).gradle(commandLine=[":<module-name>:tasks"], captureTaskOutput=":<module-name>:tasks").gradle(commandLine=[":help", "--configuration-cache"]).Property<T>, Provider<T>) or use @Internal/@Input annotations correctly.gradle_docs(query="tag:best-practices", projectRoot="/path/to/project").gradle_docs(query="tag:userguide <term>", projectRoot="/path/to/project").gradle_docs(path="dsl/org.gradle.api.Project.html", projectRoot="/path/to/project").gradle_docs(query="tag:release-notes", version="8.6").gradle_docs(query="tag:best-practices dependency management", projectRoot="/path/to/project").gradle_docs(query="tag:samples toolchains", projectRoot="/path/to/project").gradle_docs(query="tag:javadoc Project", projectRoot="/path/to/project").BuildId from the build result.query_build(buildId=ID, kind="TESTS", outcome="FAILED") to list all failed tests.query_build(buildId=ID, kind="TESTS", query=TNAME) to see the full output and stack trace for a specific test.taskPath or captureTaskOutput for test failure investigation.build, assemble, clean) with reliable, parseable output.--tests filtering, isolating failures, or retrieving full stack traces.bootRun) or continuous builds where background management is required.help, projects, tasks) without build noise.Tool: gradle
{
"commandLine": ["build"]
}
// Reasoning: Task selector (no colon) verifies build health across the entire multi-project structure.
Tool: gradle
{
"commandLine": [":app:test", "--tests", "com.example.service.MyServiceTest"]
}
// Reasoning: Absolute task path with exact class filter for the fastest possible feedback loop.
Tool: gradle
{
"commandLine": [":app:help", "--task", "test"],
"captureTaskOutput": ":app:help"
}
// Reasoning: Using captureTaskOutput to retrieve clean, isolated documentation.
Tool: gradle
{
"commandLine": [":projects"],
"captureTaskOutput": ":projects"
}
// Reasoning: Using captureTaskOutput to retrieve the project hierarchy list without startup noise.
Tool: gradle
{
"commandLine": [":properties", "--property", "version"],
"captureTaskOutput": ":properties"
}
// Reasoning: Using --property to isolate a single value and avoid retrieving thousands of unrelated properties.
Tool: gradle
{
"commandLine": [
":app:dependencyInsight",
"--dependency",
"com.google.guava:guava",
"--configuration",
"runtimeClasspath"
],
"captureTaskOutput": ":app:dependencyInsight"
}
// Reasoning: Using dependencyInsight to isolate the resolution path for a specific artifact.
Tool: gradle
// Step 1: Start the server in the background
{
"commandLine": [":app:bootRun"],
"background": true
}
// Response: { "buildId": "build_123" }
// Step 2: Wait for readiness signal
{
"buildId": "build_123",
"timeout": 60,
"waitFor": "Started Application"
}
// Reasoning: Background orchestration allows the server to remain active while waiting for readiness.
Tool: gradle_docs
{
"query": "tag:dsl signing plugin",
"projectRoot": "/absolute/path/to/project"
}
// Reasoning: Using the DSL tag to find authoritative syntax for the signing plugin configuration.
Tool: run_shell_command
{
"command": "New-Item -ItemType Directory -Force -Path subproject/src/main/kotlin"
}
// Reasoning: Creating the standard directory structure for a Kotlin JVM project using correct PowerShell syntax.
Tool: query_build
{
"buildId": "build_abc123",
"kind": "TESTS",
"outcome": "FAILED"
}
// Reasoning: Isolating only the failures from a large test suite for efficient triage.
BuildId is not recognized, it may have expired from the recent history cache. Check the dashboard (query_build()) for valid active and historical IDs.captureTaskOutput matches exactly one of the tasks in the commandLine.invocationArguments: { envSource: "SHELL" } if Gradle cannot find expected env vars (e.g., JAVA_HOME).gradle_docs.gradle_docs for authoritative documentation.tools
Reads and searches source code across ALL scopes: external library dependencies, plugins (buildscript), and Gradle Build Tool internal source code; use whenever you need to UNDERSTAND an API — its shape, signature, parameters, overloads, or implementation — before writing any code that calls it; covers project dependencies (via project/configuration/source set scope), plugins (via `sourceSetPath=":buildscript"`), and Gradle internals (via `gradleSource: true`). Prefer this over the REPL for all API research; reading source is instantaneous and complete. Do NOT use for project source code (use grep/tilth), Gradle documentation (use `gradle_docs` via the `gradle` skill), or Maven Central discovery (use `managing_gradle_dependencies`).
development
Audits and manages Gradle dependency graphs with high-resolution update checks, transitive tree analysis, and Maven Central discovery; use for dependency auditing, finding stable updates, and resolving GAV coordinates. Do NOT use for exploring dependency source code (use `exploring_dependency_sources`) or running builds/tests (use `gradle`).
development
Executes Kotlin code interactively within the project's full JVM classpath. Use when you need to RUN code: verify runtime behavior, experiment with logic, or render Compose UI previews. Do NOT use to understand an API's shape or signature — read its source with `exploring_dependency_sources` instead.
tools
Reads and searches source code of external library dependencies, plugins, and Gradle Build Tool source code. Use this whenever you need to UNDERSTAND an API: its shape, signature, parameters, overloads, or implementation — before writing any code that calls it. Prefer this over the REPL for all API research; reading source is instantaneous and complete. Do NOT use for project source code (use grep/tilth), Gradle documentation (use `researching_gradle_internals`), or Maven Central discovery (use `managing_gradle_dependencies`).