jetbrains-rules-template.md•7.62 kB
# JetBrains IDE Rules Template (IntelliJ IDEA, WebStorm, PyCharm, etc.)
## Generated by MCP ADR Analysis Server
**Purpose**: Configure JetBrains IDEs for `{PROJECT_NAME}` with intelligent code analysis and architectural compliance.
## Project Configuration
### Code Style Settings
```xml
<code_scheme name="ProjectScheme" version="1">
  <option name="LINE_SEPARATOR" value="
" />
  <option name="RIGHT_MARGIN" value="120" />
  <JavaCodeStyleSettings>
    <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
    <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
  </JavaCodeStyleSettings>
  <TypeScriptCodeStyleSettings>
    <option name="USE_SEMICOLON_AFTER_STATEMENT" value="true" />
    <option name="FORCE_SEMICOLON_STYLE" value="true" />
  </TypeScriptCodeStyleSettings>
</code_scheme>
```
### Inspection Profiles
```xml
<profile version="1.0">
  <option name="myName" value="Project Architecture" />
  <inspection_tool class="ArchitectureViolation" enabled="true" level="ERROR" />
  <inspection_tool class="SecurityVulnerability" enabled="true" level="WARNING" />
  <inspection_tool class="TestCoverage" enabled="true" level="WARNING">
    <option name="minimumCoverage" value="80" />
  </inspection_tool>
</profile>
```
## Live Templates
### ADR Template
```xml
<template name="adr" value="# $TITLE$

## Status
$STATUS$

## Context
$CONTEXT$

## Decision
$DECISION$

## Consequences
$CONSEQUENCES$" description="Create ADR" toReformat="true" toShortenFQNames="true">
  <variable name="TITLE" expression="" defaultValue=""Decision Title"" alwaysStopAt="true" />
  <variable name="STATUS" expression="" defaultValue=""Proposed"" alwaysStopAt="true" />
  <variable name="CONTEXT" expression="" defaultValue=""Context"" alwaysStopAt="true" />
  <variable name="DECISION" expression="" defaultValue=""Decision"" alwaysStopAt="true" />
  <variable name="CONSEQUENCES" expression="" defaultValue=""Consequences"" alwaysStopAt="true" />
</template>
```
### Test Template
```xml
<template name="test" value="@Test
public void should$METHOD_NAME$() {
    // Given
    $GIVEN$
    
    // When
    $WHEN$
    
    // Then
    $THEN$
}" description="Test method" toReformat="true">
  <variable name="METHOD_NAME" expression="camelCase()" defaultValue="" alwaysStopAt="true" />
  <variable name="GIVEN" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="WHEN" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="THEN" expression="" defaultValue="" alwaysStopAt="true" />
</template>
```
## File and Code Templates
### Service Class Template
```java
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
@RequiredArgsConstructor
public class ${NAME} {
    // Dependencies injected via constructor
    public void execute() {
        log.info("Executing ${NAME}");
        // Implementation following architectural patterns
    }
}
```
## Run Configurations
### Architecture Validation
```xml
<configuration name="Validate Architecture" type="ShConfigurationType">
  <option name="SCRIPT_TEXT" value="mcp-adr-tool validate-rules --project $PROJECT_DIR$" />
  <option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
</configuration>
```
### Test Coverage
```xml
<configuration name="Test with Coverage" type="JUnit">
  <option name="TEST_OBJECT" value="directory" />
  <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
  <option name="VM_PARAMETERS" value="-ea" />
  <option name="PARAMETERS" value="" />
  <patterns>
    <pattern testClass=".*Test" />
  </patterns>
</configuration>
```
## External Tools
### MCP ADR Analysis
```xml
<toolSet name="MCP ADR Tools">
  <tool name="Analyze Ecosystem" showInMainMenu="true" showInEditor="true">
    <exec>
      <option name="COMMAND" value="mcp-adr-tool" />
      <option name="PARAMETERS" value="analyze-ecosystem --path $FilePath$" />
      <option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
    </exec>
  </tool>
  <tool name="Generate ADR" showInMainMenu="true">
    <exec>
      <option name="COMMAND" value="mcp-adr-tool" />
      <option name="PARAMETERS" value="generate-adr --context $Prompt$" />
      <option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
    </exec>
  </tool>
</toolSet>
```
## Intentions and Quick Fixes
### Architecture Compliance
```xml
<intentionAction>
  <className>com.project.intentions.FixArchitectureViolation</className>
  <category>Architecture</category>
  <description>Fix architecture layer violation</description>
</intentionAction>
```
### Security Fixes
```xml
<intentionAction>
  <className>com.project.intentions.SecureCodePattern</className>
  <category>Security</category>
  <description>Apply secure coding pattern</description>
</intentionAction>
```
## Database Tools
### Query Console Templates
```sql
-- Analyze table performance
EXPLAIN ANALYZE
SELECT *
FROM ${TABLE_NAME}
WHERE ${CONDITION};
-- Migration template
BEGIN;
-- Migration: ${DESCRIPTION}
${MIGRATION_SQL}
COMMIT;
```
## Version Control Integration
### Commit Templates
```
[${TYPE}] ${SUBJECT}
${BODY}
Related ADR: ${ADR_NUMBER}
Closes: ${ISSUE_NUMBER}
```
### Pre-commit Checks
```xml
<vcs-settings>
  <option name="PERFORM_ROLLBACK_IN_BACKGROUND" value="false" />
  <option name="CHECK_CODE_SMELLS_BEFORE_COMMIT" value="true" />
  <option name="CHECK_NEW_TODO_BEFORE_COMMIT" value="true" />
  <option name="FORCE_NON_EMPTY_COMMENT" value="true" />
</vcs-settings>
```
## AI Assistant Configuration
### Context Rules
```yaml
ai_assistant:
  include_context:
    - current_class
    - related_tests
    - architectural_patterns
    - project_conventions
  code_generation:
    - follow_existing_patterns
    - maintain_layer_boundaries
    - include_logging
    - handle_exceptions
  suggestions:
    - performance_optimizations
    - security_improvements
    - test_coverage_gaps
```
## Project Structure
### Module Templates
```
src/
├── main/
│   ├── java/
│   │   └── ${PACKAGE}/
│   │       ├── domain/
│   │       ├── application/
│   │       ├── infrastructure/
│   │       └── presentation/
│   └── resources/
└── test/
    ├── java/
    └── resources/
```
## Custom Actions
### Keyboard Shortcuts
```xml
<keymap version="1" name="Project Keymap">
  <action id="AnalyzeArchitecture" class="com.project.actions.AnalyzeArchitecture">
    <keyboard-shortcut first-keystroke="ctrl shift A" />
  </action>
  <action id="GenerateTests" class="com.project.actions.GenerateTests">
    <keyboard-shortcut first-keystroke="ctrl shift T" />
  </action>
  <action id="ValidateDeployment" class="com.project.actions.ValidateDeployment">
    <keyboard-shortcut first-keystroke="ctrl shift D" />
  </action>
</keymap>
```
## IDE Scopes
### Architecture Scopes
```xml
<scope name="Domain Layer" pattern="file:src/main/java/*/domain//*" />
<scope name="Application Layer" pattern="file:src/main/java/*/application//*" />
<scope name="Infrastructure Layer" pattern="file:src/main/java/*/infrastructure//*" />
<scope name="Tests" pattern="file:src/test//*" />
```
## Custom Configuration
Add your JetBrains IDE specific customizations:
```xml
<!-- Your project-specific configurations -->
```