Skip to main content
Glama

apply_quality_rules

Read-onlyIdempotent

Enforce coding standards and conventions for naming, structure, TypeScript, React, accessibility, or all scopes to maintain consistent code quality across JavaScript, TypeScript, React, Vue, or general programming contexts.

Instructions

규칙 적용|표준 적용|apply rules|apply standards|follow conventions|적용해 - Apply quality rules

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scopeYesApplication scope
languageNoProgramming language context

Implementation Reference

  • The main handler function that takes scope and optional language arguments, selects applicable quality rules, constructs a result object, and returns formatted content describing the applied rules.
    export async function applyQualityRules(args: { scope: string; language?: string }): Promise<ToolResult> {
      const { scope, language: contextLanguage = 'general' } = args;
      
      const applicableRules = [];
      
      if (scope === 'naming' || scope === 'all') {
        applicableRules.push({
          category: 'Naming Conventions',
          rules: QUALITY_RULES.NAMING
        });
      }
      
      if (scope === 'structure' || scope === 'all') {
        applicableRules.push({
          category: 'Code Structure',
          rules: QUALITY_RULES.STRUCTURE
        });
      }
      
      if (scope === 'typescript' || scope === 'all') {
        applicableRules.push({
          category: 'TypeScript Guidelines',
          rules: QUALITY_RULES.ANTIPATTERNS.typescript
        });
      }
      
      if (scope === 'react' || scope === 'all') {
        applicableRules.push({
          category: 'React Guidelines',
          rules: QUALITY_RULES.ANTIPATTERNS.react
        });
      }
      
      if (scope === 'accessibility' || scope === 'all') {
        applicableRules.push({
          category: 'Accessibility Guidelines',
          rules: [
            'Use semantic HTML elements',
            'Provide alt text for images',
            'Ensure keyboard navigation',
            'Maintain color contrast ratios',
            'Use ARIA labels when needed'
          ]
        });
      }
      
      const qualityRulesResult = {
        action: 'apply_quality_rules',
        scope,
        language: contextLanguage,
        rules: applicableRules,
        asyncStates: QUALITY_RULES.ASYNC_STATES,
        stateManagement: QUALITY_RULES.STATE_MANAGEMENT,
        status: 'success'
      };
      
      const rulesSummary = applicableRules.map(r => `${r.category}: ${Array.isArray(r.rules) ? r.rules.length + ' rules' : Object.keys(r.rules).length + ' items'}`).join(', ');
      return {
        content: [{ type: 'text', text: `Scope: ${scope}\nLanguage: ${contextLanguage}\nRules Applied: ${rulesSummary}\n\nAsync States: ${QUALITY_RULES.ASYNC_STATES.join(', ')}\n\nState Mgmt:\n${Object.entries(QUALITY_RULES.STATE_MANAGEMENT).map(([k, v]) => `- ${k}: ${v}`).join('\n')}` }]
      };
    }
  • The ToolDefinition export that specifies the tool's name, description, input schema (with scope required and language optional), and annotations indicating usage hints.
    export const applyQualityRulesDefinition: ToolDefinition = {
      name: 'apply_quality_rules',
      description: '규칙 적용|표준 적용|apply rules|apply standards|follow conventions|적용해 - Apply quality rules',
      inputSchema: {
        type: 'object',
        properties: {
          scope: { type: 'string', description: 'Application scope', enum: ['naming', 'structure', 'typescript', 'react', 'accessibility', 'all'] },
          language: { type: 'string', description: 'Programming language context', enum: ['javascript', 'typescript', 'react', 'vue', 'general'] }
        },
        required: ['scope']
      },
      annotations: {
        title: 'Apply Quality Rules',
        audience: ['user', 'assistant'],
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: false
      }
    };
  • src/index.ts:88-145 (registration)
    The tools array registration where applyQualityRulesDefinition is included among other tool definitions for the ListTools endpoint.
    const tools = [
      // Core Utilities (2)
      getCurrentTimeDefinition,
      previewUiAsciiDefinition,
    
      // Memory Management - Basic (6)
      saveMemoryDefinition,
      recallMemoryDefinition,
      updateMemoryDefinition,
      deleteMemoryDefinition,
      listMemoriesDefinition,
      prioritizeMemoryDefinition,
    
      // Memory Management - Graph (4) - v2.0 NEW
      linkMemoriesDefinition,
      getMemoryGraphDefinition,
      searchMemoriesAdvancedDefinition,
      createMemoryTimelineDefinition,
    
      // Memory Management - Session Context (1) - v2.1 NEW
      getSessionContextDefinition,
    
      // Code Analysis - Semantic (2)
      findSymbolDefinition,
      findReferencesDefinition,
    
      // Code Analysis - Advanced (1) - v2.0 NEW
      analyzeDependencyGraphDefinition,
    
      // Code Quality (6)
      getCodingGuideDefinition,
      applyQualityRulesDefinition,
      validateCodeQualityDefinition,
      analyzeComplexityDefinition,
      checkCouplingCohesionDefinition,
      suggestImprovementsDefinition,
    
      // Thinking & Planning (8)
      createThinkingChainDefinition,
      analyzeProblemDefinition,
      stepByStepAnalysisDefinition,
      formatAsPlanDefinition,
      generatePrdDefinition,
      createUserStoriesDefinition,
      analyzeRequirementsDefinition,
      featureRoadmapDefinition,
    
      // Prompt Engineering (3)
      enhancePromptDefinition,
      analyzePromptDefinition,
      enhancePromptGeminiDefinition,
    
      // Reasoning (1)
      applyReasoningFrameworkDefinition,
    
      // Analytics (1) - v2.0 NEW
      getUsageAnalyticsDefinition
    ];
  • src/index.ts:155-212 (registration)
    The toolHandlers object registration mapping 'apply_quality_rules' to the applyQualityRules handler function for dynamic tool dispatch.
    const toolHandlers: Record<string, ToolHandler> = {
      // Time & UI
      'get_current_time': getCurrentTime,
      'preview_ui_ascii': previewUiAscii,
    
      // Memory - Basic
      'save_memory': saveMemory,
      'recall_memory': recallMemory,
      'update_memory': updateMemory,
      'delete_memory': deleteMemory,
      'list_memories': listMemories,
      'prioritize_memory': prioritizeMemory,
    
      // Memory - Graph (v2.0 NEW)
      'link_memories': linkMemories,
      'get_memory_graph': getMemoryGraph,
      'search_memories_advanced': searchMemoriesAdvanced,
      'create_memory_timeline': createMemoryTimeline,
    
      // Memory - Session Context (v2.1 NEW)
      'get_session_context': getSessionContext,
    
      // Code Analysis
      'find_symbol': findSymbol,
      'find_references': findReferences,
      'analyze_dependency_graph': analyzeDependencyGraph,
    
      // Code Quality
      'get_coding_guide': getCodingGuide,
      'apply_quality_rules': applyQualityRules,
      'validate_code_quality': validateCodeQuality,
      'analyze_complexity': analyzeComplexity,
      'check_coupling_cohesion': checkCouplingCohesion,
      'suggest_improvements': suggestImprovements,
    
      // Thinking
      'create_thinking_chain': createThinkingChain,
      'analyze_problem': analyzeProblem,
      'step_by_step_analysis': stepByStepAnalysis,
      'format_as_plan': formatAsPlan,
    
      // Planning
      'generate_prd': generatePrd,
      'create_user_stories': createUserStories,
      'analyze_requirements': analyzeRequirements,
      'feature_roadmap': featureRoadmap,
    
      // Prompt
      'enhance_prompt': enhancePrompt,
      'analyze_prompt': analyzePrompt,
      'enhance_prompt_gemini': enhancePromptGemini,
    
      // Reasoning
      'apply_reasoning_framework': applyReasoningFramework,
    
      // Analytics (v2.0 NEW)
      'get_usage_analytics': getUsageAnalytics
    };
  • The central QUALITY_RULES constant object defining all naming conventions, structure rules, antipatterns, async states, and state management guidelines used by the handler.
    // Code Quality Standards
    const QUALITY_RULES = {
      NAMING: {
        variables: 'nouns (userList, userData)',
        functions: 'verb+noun (fetchData, updateUser)',
        events: 'handle prefix (handleClick, handleSubmit)',
        booleans: 'is/has/can prefix (isLoading, hasError, canEdit)',
        constants: 'UPPER_SNAKE_CASE (MAX_RETRY_COUNT, API_TIMEOUT)',
        components: 'PascalCase (UserProfile, HeaderSection)',
        hooks: 'use prefix (useUserData, useAuth)'
      },
      STRUCTURE: {
        componentOrder: ['State & Refs', 'Custom Hooks', 'Event Handlers', 'Effects', 'Early returns', 'Main return JSX'],
        functionMaxLines: 20,
        componentMaxLines: 50,
        maxNestingDepth: 3
      },
      ANTIPATTERNS: {
        typescript: ['any type usage', '@ts-ignore usage', 'as any casting'],
        react: ['dangerouslySetInnerHTML', 'props drilling (3+ levels)'],
        javascript: ['var usage', '== instead of ===', 'eval() usage'],
        css: ['!important abuse', 'inline style abuse']
      },
      ASYNC_STATES: ['data', 'isLoading', 'error'],
      STATE_MANAGEMENT: {
        simple: 'useState',
        complex: 'useReducer',
        globalUI: 'Context API',
        globalApp: 'Zustand',
        server: 'TanStack Query'
      }
    };
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations provide comprehensive behavioral information (readOnlyHint=true, destructiveHint=false, idempotentHint=true, openWorldHint=false), so the description's burden is reduced. The description doesn't contradict these annotations, but also adds no meaningful behavioral context beyond what's already in structured fields. No information about what 'applying' entails operationally, side effects, or implementation details is provided.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

While technically brief, the description is poorly structured and contains redundant synonyms that don't add value. The multilingual repetition ('규칙 적용|표준 적용|apply rules|apply standards|follow conventions|적용해') creates noise without improving understanding. This isn't effective conciseness but rather under-specification disguised as brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a tool with 2 parameters (one required), no output schema, and annotations covering safety aspects, the description is inadequate. It doesn't explain what 'applying quality rules' means operationally, what the tool actually does, or what kind of output/result to expect. For a tool that presumably performs some meaningful operation on code/quality standards, this leaves too much undefined.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with both parameters having clear descriptions and enumerated values, so the baseline is 3. The description adds no additional parameter information beyond what's in the schema - it doesn't explain how 'scope' and 'language' interact, provide examples of valid combinations, or clarify the meaning of 'all' scope or 'general' language context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description is essentially a tautology that restates the tool name with synonyms ('규칙 적용|표준 적용|apply rules|apply standards|follow conventions|적용해 - Apply quality rules'). It doesn't specify what 'applying quality rules' actually means operationally - whether it's validation, transformation, analysis, or something else. While it distinguishes from siblings by focusing on 'quality rules' rather than analysis or creation tasks, the purpose remains vague.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives. The description doesn't mention any prerequisites, appropriate contexts, or comparison to sibling tools like 'validate_code_quality' or 'suggest_improvements' that might serve similar functions. The agent must infer usage purely from the tool name and parameters.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/su-record/hi-ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server