| name | implement-rule-from-jira |
| description | Use when user wants to create a new validation rule from a Jira ticket (Story type only) - validates ticket, scaffolds rule with tests and Confluence docs |
Create a new in-cluster validation rule from a Jira ticket.
Args: Jira ticket number (e.g., PDRIVE-123)
Purpose: This skill helps external contributors implement new validation rules according to project guidelines. It validates the ticket type, scaffolds the rule, creates tests, generates Confluence documentation, and handles the complete PR workflow.
Implement New Rule from Jira Ticket
You are helping an external contributor create a new in-cluster validation rule from a Jira ticket.
Step 1: Validate Ticket Type
CRITICAL: This skill is ONLY for creating new validation rules, not general implementation tasks.
-
Fetch the Jira ticket:
- Use
mcp__plugin_atlassian_atlassian__getJiraIssue with the ticket number
- Extract: title, description, issue type, acceptance criteria
-
Validate issue type:
-
If validation passes, proceed to present ticket information:
- Ticket: [TICKET-NUMBER] Title
- Type: Story
- Priority: High/Medium/Low
- Description: (formatted clearly)
- Acceptance Criteria: (if present)
Step 2: Git Workflow
Follow the git workflow from implement-jira exactly:
Reference: @.claude/skills/implement-jira/SKILL.md (Step 2)
-
Update main branch:
git checkout main
git fetch upstream
git rebase upstream/main
-
Create descriptive branch:
- Format:
TICKET-NUMBER_short_rule_description
- Example:
PDRIVE-553_check_disk_usage
git checkout -b PDRIVE-XXX_short-description
git branch --show-current
IMPORTANT: Only proceed after confirming the branch is created and checked out.
Step 3: Analyze Ticket for Rule Requirements
Extract from the ticket description and acceptance criteria:
- Rule name: Determine the
unique_name (e.g., is_disk_space_sufficient)
- Domain: Identify which domain to use (hw, network, linux, storage, k8s, etcd, security) or create a new domain if none fit
- Rule type: Determine if it's a
Rule or OrchestratorRule
- Objective hosts: Which nodes to run on (ALL_NODES, MASTERS, WORKERS, etc.)
- Supported profile: Check
src/profiles/profiles.yaml for available profiles and ask the user which profile this rule should target. Only use "general" if the rule applies to ALL cluster types.
- Validation logic: What command(s) to run and what to check
Present this analysis to the user and ask for confirmation before proceeding.
Step 4: Create the Rule
Follow rule creation guidelines from:
- @.claude/skills/new-rule/SKILL.md
- @.claude/rules/in-cluster-check.md
4a. Create Rule Class
Place the rule in src/in_cluster_checks/rules/<domain>/<file>.py:
- Use appropriate rule type (Rule or OrchestratorRule)
- Set
objective_hosts, unique_name, title
- Implement
run_rule() returning RuleResult
- Add
is_prerequisite_fulfilled() if needed
- CRITICAL: All commands MUST use
SafeCmdString
- Add Confluence link to
links field (see Step 6 for URL format)
Important reminders:
- NO use of
self.logger - return messages via RuleResult
- Use
UnExpectedSystemOutput for command failures
- Follow all guidelines from
.claude/rules/code-style.md
- Place ALL imports at the top of the file
4b. Register in Domain
Add the rule to the domain in src/in_cluster_checks/domains/<domain>.py:
from in_cluster_checks.rules.<domain>.<file> import NewRuleName
class SomeDomain(RuleDomain):
def get_rule_classes(self) -> List[type]:
return [
NewRuleName,
]
Step 5: Write Tests
Follow test guidelines from:
- @.claude/skills/new-rule/SKILL.md (Step 4)
- @.claude/rules/testing.md
Create tests in tests/rules/<domain>/test_<file>.py:
- Use
RuleTestBase framework
- Define
scenario_passed and scenario_failed
- Command strings MUST match exactly what the rule executes
- Use
CmdOutput for mocking command results
- Update domain test file to include the new rule
Run tests:
source .venv/bin/activate
pytest tests/rules/<domain>/test_<file>.py -v
Ensure all tests pass before proceeding.
Step 6: Create Confluence Documentation Page
REQUIRED: Every new rule MUST have Confluence documentation.
Reference: @.claude/rules/in-cluster-check.md (Documentation section)
6a. Review Existing Template
Read an existing Confluence page as a template using Confluence MCP:
6b. Create Documentation Page via Confluence MCP
Create the page directly using mcp__plugin_atlassian_atlassian__createConfluencePage.
Page title: Use the rule's title field exactly (e.g., "Verify infrastructure pods are ready and running").
Domain parent page IDs (space ID: 377096307):
- DPF:
418450735
- Hardware:
418418340
- K8s:
418516155
- Linux:
418482835
- Network:
418482854
- Resources:
418450807
- Security:
418516403
Standard Structure (use contentFormat: "html"):
- Description: What the rule checks, why it's important, severity, failure thresholds
- Prerequisites: Required access, tools, or conditions
- Impact: What happens if the condition fails
- Root Cause: Common reasons for failure
- Diagnostics: Commands to investigate manually
- Solution: Step-by-step remediation with code examples
- Resources: Links to official docs, KCS articles, guides
See @.claude/rules/confluence-guidelines.md for detailed formatting rules.
6c. Add Confluence Link to Rule
After page creation, the MCP tool returns the page ID. Add the link to the rule's links field:
links = ["https://redhat.atlassian.net/wiki/spaces/PDRIVE/pages/{PAGE_ID}"]
Step 7: Run All Tests
Before committing, ensure everything works:
source .venv/bin/activate
pytest tests/rules/<domain>/test_<file>.py -v
pytest --cov=src/in_cluster_checks --cov-report=term-missing
pre-commit run --all-files
All checks must pass before proceeding.
Step 8: Ready to Commit?
IMPORTANT: Ask the user if they're ready to commit the changes.
Show summary:
- Rule class created:
src/in_cluster_checks/rules/<domain>/<file>.py
- Tests created:
tests/rules/<domain>/test_<file>.py
- Domain updated:
src/in_cluster_checks/domains/<domain>.py
- All tests passing
Wait for user confirmation.
When committing:
- Use conventional commits format:
feat(TICKET-NUMBER): add <rule-title>
- Follow commit attribution rules from
.claude/rules/git-workflow.md
- Include ticket number in commit message
Step 9: Ensure Latest Code
Reference: @.claude/skills/implement-jira/SKILL.md (Step 7)
After committing, rebase on upstream:
git fetch upstream
git rebase upstream/main
Guide the user through any conflicts if they occur.
Step 10: Push the Branch
git push -u origin <branch-name>
Step 11: Create Pull Request
Follow GitHub MCP guidelines from: @.claude/rules/github-mcp.md
Use mcp__plugin_github_github__create_pull_request:
CRITICAL - Get User Approval First:
- Show the proposed PR title, body, head, base
- MUST wait for explicit user confirmation before creating
PR Details:
Return the PR URL to the user.
Step 12: Update Jira Ticket (Optional)
Offer to update the Jira ticket with implementation details:
MUST ask user for approval first - Show what will be added:
## Implementation Summary
Created new validation rule: `<unique_name>`
**Files Created/Updated:**
- `src/in_cluster_checks/rules/<domain>/<file>.py` - Rule implementation
- `tests/rules/<domain>/test_<file>.py` - Test coverage
- `src/in_cluster_checks/domains/<domain>.py` - Domain registration
**Pull Request:** [PR #NUMBER](PR-URL)
**Documentation:** [Rule Documentation Page](confluence-url)
**Status:** Ready for review
Use mcp__plugin_atlassian_atlassian__addCommentToJiraIssue with contentFormat: "markdown".
Error Handling
- Invalid ticket number: Inform user and exit
- Wrong issue type: Show error message (Step 1) and exit
- Git operation failure: Show error, suggest fixes (e.g., add upstream remote)
- Branch already exists: Ask if they want to switch to it or create different branch
- Tests fail: Show failures, help debug before allowing commit
- Missing upstream remote: Suggest
git remote add upstream https://github.com/RedHatInsights/incluster-checks.git
Checklist
Before marking complete, verify:
Example Workflow
User: /implement-rule-from-jira PDRIVE-505
Expected flow:
1. Fetch PDRIVE-505 from Jira
2. Validate issue type is "Story" ✓
3. Update main and create branch: PDRIVE-505_network_connectivity_check
4. Show ticket details and ask for confirmation
5. Analyze ticket → determine it's a network rule for ALL_NODES
6. Create rule in src/in_cluster_checks/rules/network/
7. Register in NetworkValidationDomain
8. Create tests in tests/rules/network/
9. Create Confluence documentation page via MCP under Network domain
10. Run tests → all pass ✓
11. Commit with: feat(PDRIVE-505): add network connectivity validation
12. Rebase on upstream/main
13. Push to origin
14. Show proposed PR details → user approves → create PR
15. Offer to update Jira ticket → user approves → add comment with PR link