Gradle-mcp gradle_expert
install
source · Clone the upstream repo
git clone https://github.com/rnett/gradle-mcp
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/rnett/gradle-mcp "$T" && mkdir -p ~/.claude/skills && cp -r "$T/src/main/skills/gradle_expert" ~/.claude/skills/rnett-gradle-mcp-gradle-expert && rm -rf "$T"
manifest:
src/main/skills/gradle_expert/SKILL.mdsource content
Senior Gradle Build Engineering & Internal Research
Provides authoritative guidance and automation for creating, modifying, and auditing Gradle build logic. Integrates official documentation, best practices, and deep-dive source research into a unified workflow for build logic maintenance.
Constitution
- ALWAYS check for existing conventions in the current project before proposing changes.
- ALWAYS prefer Kotlin DSL (
) unless the project explicitly uses Groovy..kts - ALWAYS use lazy APIs (e.g.,
instead ofregister
) to maintain configuration performance.create - ALWAYS use
for dependency management if it exists.libs.versions.toml - ALWAYS use
for authoritative documentation lookup instead of generic web searches.gradle_docs - ALWAYS use
withsearch_dependency_sources
when researching core Gradle behavior.gradleSource = true - ALWAYS use
withsearch_dependency_sources
when researching plugin (buildscript) source code. This targets the virtualsourceSetPath = ":buildscript"
source set which aggregates all classpath plugins.buildscript - ALWAYS use
withinspect_build
andtestName
for individual test output instead of genericmode="details"
,taskPath
, or shellcaptureTaskOutput
.grep - ALWAYS use safe navigation (
) and provide fallback values when accessing?.url?.toString()
URLs in Gradle init scripts or plugins to preventArtifactRepository
.NullPointerException - STRONGLY PREFERRED: Use
for all failure diagnostics. It is more token-efficient than reading raw console logs and provides structured access to failures, stack traces, and problems.inspect_build - NEVER guess internal API behavior; verify it by reading the source code of the Gradle Build Tool.
Surgical Failure Diagnostics with inspect_build
inspect_buildAs a Senior Build Engineer, you must move beyond raw logs. The
inspect_build tool is your surgical diagnostic suite.
1. Build Summary (Finding the Root Cause)
Start with a summary to find IDs for specific failures or problems.
- Example:
inspect_build(buildId="ID")
2. Individual Test Failures
CRITICAL: NEVER use
taskPath or shell grep for tests. ALWAYS use testName with mode="details" to see the full output and stack trace.
- Example:
inspect_build(buildId="ID", mode="details", testName="com.example.MyTest.shouldWork")
3. Build-Level Failures
For compilation or configuration errors, use
failureId found in the build summary.
- Example:
inspect_build(buildId="ID", mode="details", failureId="F0")
4. Problems & Warnings
For deep-dives into specific problems (e.g., deprecations, plugin issues), use
problemId.
- Example:
inspect_build(buildId="ID", mode="details", problemId="P1")
Directives
- Author builds idiomatically: Use standard patterns for multi-project builds and convention plugins.
- Perform performance audits: Identify configuration bottlenecks and recommend lazy API migrations.
- Research internals authoritatively: Use
and internal source search to understand "how it works" at the engine level. Usegradle_docs
to explore implementation details. To search a plugin, useread_dependency_sources
.sourceSetPath=":buildscript" - Diagnose failures surgically: Use
withinspect_build
andtestName
to analyze test failures and stack traces instead of reading raw console logs. DO NOT usemode="details"
ortaskPath
for tests.captureTaskOutput - Resolve dependencies precisely: Use
andinspect_dependencies
for auditing and updates.managing_gradle_dependencies- Default Exclusion: Buildscript (plugin) dependencies are excluded by default from reports and searches. Use
to include them in reports.excludeBuildscript: false - Virtual Buildscript Source Set: Use
(orsourceSetPath = ":buildscript"
) to precisely audit the plugin classpath. This aggregates all:app:buildscript
configurations.buildscript { ... }
- Default Exclusion: Buildscript (plugin) dependencies are excluded by default from reports and searches. Use
- Consult best practices: Refer to the Best Practices Snapshot for a high-level overview. ALWAYS use
withgradle_docs
to retrieve the latest and most comprehensive guidelines from the official documentation.tag:best-practices - Use
if environment variables are missing: If Gradle fails to find expected environment variables (e.g.,envSource: SHELL
or specific JDKs), it may be because the host process started before the shell environment was fully loaded. SetJAVA_HOME
to force a new shell process to query the environment.invocationArguments: { envSource: "SHELL" }
Workflows
1. Creating a New Module
- Identify the Project Context: Use the
tool withgradle
or thecommandLine: ["projects"]
skill to find the correct parent path.introspecting_gradle_projects - Create Directory Structure: Use
withrun_shell_command
(or equivalent).mkdir subproject/src/main/kotlin - Add to
: Usesettings.gradle.kts
orreplace
to appendwrite_file
.include(":<module-name>") - Create
: Use idiomatic patterns (e.g., applying convention plugins).build.gradle.kts - Verify: Run the
tool withgradle
to ensure it's correctly integrated.commandLine: [":<module-name>:tasks"]
2. Adding a Dependency
- Search Maven Central: Use the
tool to find the artifact.lookup_maven_versions - Update
: Add the dependency coordinates to the catalog.libs.versions.toml - Apply to
: Use the type-safe accessor from the catalog.build.gradle.kts - Verify: Run
to check resolution.inspect_dependencies(fresh: true) - Plugins: If adding a plugin, verify its resolution using
.inspect_dependencies(sourceSetPath = ":buildscript")
3. Performance Audit
- Enable Configuration Cache: Run the
tool withgradle
.commandLine: ["help", "--configuration-cache"] - Analyze Violations: Identify tasks that are not compatible with the cache.
- Propose Fixes: Recommend migrating to lazy APIs (
,Property
) or usingProvider
/@Internal
correctly.@Input
Examples
Adding a new dependency to a module
Tool:
lookup_maven_versions
{ "coordinates": "com.google.guava:guava" }
// Reasoning: Searching Maven Central for the exact coordinates and latest version.
Creating a new sub-project
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.
Searching for Gradle internal engine source code
Tool:
search_dependency_sources
{ "query": "Property", "searchType": "DECLARATION", "gradleSource": true }
When to Use
- New Module Creation: When adding a new project or module to a multi-project build.
- Dependency Migration: When updating dependencies or moving to version catalogs.
- Build Logic Refactoring: When cleaning up complex build scripts or creating convention plugins.
- Performance Troubleshooting: When builds are slow or failing during the configuration phase.
- Deep Technical Research: When you need to understand the internal implementation of a Gradle feature or plugin.