Skip to main content
Glama

apply_quality_rules

Apply quality rules to code for naming, structure, TypeScript, React, accessibility, or all standards to ensure code follows conventions and maintains quality.

Instructions

apply rules|apply standards|apply rules|apply standards|follow conventions|apply - Apply quality rules

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scopeYesApplication scope
languageNoProgramming language context

Implementation Reference

  • The primary handler function for the 'apply_quality_rules' tool. It destructures the input arguments, selects applicable quality rules based on the provided scope (naming, structure, typescript, react, accessibility, or all), constructs a result object, and returns a formatted ToolResult with summaries of applied rules, async states, and state management recommendations.
    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 object defining the tool's name, description, input schema (requiring 'scope' with specific enums and optional 'language'), and annotations for UI display.
    export const applyQualityRulesDefinition: ToolDefinition = {
      name: 'apply_quality_rules',
      description: 'apply rules|apply standards|apply rules|apply standards|follow conventions|apply - 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']
      }
    };
  • src/index.ts:660-661 (registration)
    Registration in the central tool dispatcher switch statement within executeToolCall function; routes 'apply_quality_rules' calls to the imported applyQualityRules handler.
    case 'apply_quality_rules':
      return await applyQualityRules(args as any) as CallToolResult;
  • src/index.ts:138-138 (registration)
    Inclusion of the tool definition in the central 'tools' array used for listing available tools via ListToolsRequestSchema.
    applyQualityRulesDefinition,
  • Central constant object defining all quality rules, antipatterns, async states, and state management guidelines used by the handler to populate applicable rules.
    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'
      }
    };
Behavior2/5

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

No annotations are provided beyond a basic title, so the description carries full burden for behavioral disclosure. The description only vaguely suggests applying rules/standards but doesn't reveal whether this is a read-only analysis, a mutation that changes code, whether it requires specific permissions, what the output format might be, or any rate limits. For a tool with no annotation coverage, this leaves critical behavioral traits undisclosed.

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

Conciseness1/5

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

The description is poorly structured and repetitive with phrases like 'apply rules|apply standards|apply rules|apply standards|follow conventions|apply' that don't form coherent sentences. It appears to be keyword stuffing rather than meaningful content. This wastes space without providing useful information and fails to be front-loaded with clear purpose.

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 the tool has no output schema and minimal annotations (only a title), the description should provide more complete context about what the tool actually does and returns. The current description is completely inadequate - it doesn't explain what 'quality rules' are, what resources they're applied to, what the expected outcome is, or any behavioral characteristics. For a tool with 2 parameters and no output documentation, this leaves too many gaps.

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 enum values in the schema. The description adds no additional information about parameter meaning, constraints, or usage beyond what's already documented in the schema. With high schema coverage, the baseline score of 3 is appropriate since the schema does the heavy lifting for parameter documentation.

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 a tautology that essentially restates the tool name 'apply_quality_rules' with repetitive synonyms like 'apply rules', 'apply standards', 'follow conventions'. It doesn't specify what quality rules are being applied, to what resources, or what the actual outcome is. While it suggests applying rules/standards/conventions, this is too vague to distinguish from sibling tools like 'validate_code_quality' or 'get_coding_guide'.

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

Usage Guidelines1/5

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

The description provides absolutely no guidance on when to use this tool versus alternatives. There's no mention of context, prerequisites, or comparison to sibling tools like 'validate_code_quality' or 'get_coding_guide' that might serve similar purposes. The agent receives no help in deciding when this specific tool is appropriate.

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/ssdeanx/ssd-ai'

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