Agent skill
fix-intellij-observations
Fix IntelliJ observations in changed files. Use when the user asks to fix IntelliJ observations, warnings, inspections, or code problems. No need to list specific warnings — the skill discovers them automatically.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/fix-intellij-observations
SKILL.md
Fix IntelliJ Observations
Fix all IntelliJ IDEA observations (both warnings AND errors) in changed files. The skill automatically discovers which files to check and what problems exist — the user does NOT need to list specific warnings or errors.
Workflow
Step 1: Identify changed files
Determine which files need inspection using the following priority:
Priority 1 — Changed but not staged files
Run git diff --name-only (unstaged changes) and git diff --cached --name-only (staged changes). If either returns results, use that combined set of files as the target list.
Priority 2 — Diff against base branch
If there are NO unstaged or staged changes (working tree is clean), fall back to comparing against the base branch:
-
Try to detect the base branch from a pull request. Run:
bashgh pr view --json baseRefName --jq '.baseRefName' 2>/dev/nullIf this succeeds and returns a branch name, use that as the base branch.
-
If no PR exists (the command fails or returns empty), detect the repository's default branch:
bashgh repo view --json defaultBranchRef --jq '.defaultBranchRef.name' 2>/dev/nullIf this succeeds, use the returned branch name. Otherwise, fall back to
develop. -
Get the changed files:
bashgit diff <base-branch>...HEAD --name-only
Filtering
After obtaining the file list from either priority path:
- Filter out deleted files (i.e., files that no longer exist on disk).
- Filter to only
.javafiles. - Exclude any files under
core/src/main/java/com/jetbrains/youtrackdb/internal/core/sql/parser/(these are generated).
If no files remain after filtering, inform the user and stop.
Step 2: Get problems for each file
For each changed Java file, call mcp__jetbrains__get_file_problems with:
filePath: the file path relative to the project rooterrorsOnly: false (IMPORTANT: must be false to include both warnings AND errors)projectPath: the project root path
Process files in parallel where possible to speed up analysis.
If no problems are found across all files, inform the user and stop.
Step 3: Fix the problems
For each reported problem:
- Read the file to understand the context around the problem location
- Determine the appropriate fix based on the problem description and severity
- Apply the fix using the Edit tool or
mcp__jetbrains__replace_text_in_file - If a problem is unclear or the fix would change behavior, ask the user before proceeding
Common fixes include:
- Adding missing
@Overrideannotations - Removing unused imports or variables
- Fixing null-safety issues (adding null checks, using
@Nullable/@NotNull) - Replacing raw types with parameterized types
- Fixing redundant casts or type arguments
- Addressing deprecation warnings
- Fixing resource leak warnings (try-with-resources)
- Correcting access modifier visibility
Step 4: Verify fixes
After applying fixes, re-run mcp__jetbrains__get_file_problems (with errorsOnly: false) on each modified file to confirm all observations are resolved. If new problems were introduced, fix those too.
Step 5: Build validation
Run mcp__jetbrains__build_project to ensure the fixes compile correctly. If build errors occur, fix them before finishing.
Important Notes
- The user does NOT need to paste or list specific warnings/errors — this skill discovers them automatically.
- Always set
errorsOnlytofalsewhen callingget_file_problems— the goal is to fix ALL observations, not just errors. - Do not modify generated code (SQL parser files, Gremlin DSL files).
- Preserve existing code style: 2-space indent, 100-char line width, braces always required.
- If a warning is a false positive or intentional, add a suppression annotation (
@SuppressWarnings) with a comment explaining why.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?