Skip to main content
Glama

aida_log_rule

Logs project-level technical rules for AI development, capturing patterns from coding deviations to improve code quality through standardized guidelines.

Instructions

沉淀项目规则。当偏差的 rootCause 为 rule-missing 且修复方案属于项目级技术规范(非业务逻辑)时,询问用户同意后调用此工具沉淀规则。仅限:公共组件使用规范、API 调用规范、参数传递规范、代码风格/架构规范。禁止沉淀业务逻辑。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes规则内容,简洁描述项目规范
categoryYes规则分类
sourceDeviationNo关联的偏差 ID,如 DEV-01

Implementation Reference

  • The `handleLogRule` function implements the logic for the `aida_log_rule` MCP tool, which records project-level rules in both a central registry and the current session's `run.json`.
    function handleLogRule(args: any): any {
      const { path, data } = ensureRunJson();
      const branch = getBranchName();
      const dev = getDevName();
      const category = args.category || 'general';
      const content = args.content;
    
      // Write to project-level registry with fingerprint dedup
      const { entry, isDuplicate } = addRule(projectRoot, {
        content,
        category,
        branch,
        deviation: args.sourceDeviation || null,
        author: dev,
        status: 'active',
      });
    
      if (isDuplicate) {
        return { success: true, message: `规则已存在: ${entry.id}(fingerprint 重复)`, ruleId: entry.id, isDuplicate: true };
      }
    
      // Also record in run.json.rules[] for per-run tracking
      const localId = nextId(data.rules, 'RULE');
      data.rules.push({
        ruleId: localId,
        file: `rules.json#${entry.id}`,
        content,
        sourceDeviation: args.sourceDeviation || null,
        sedimentedAt: now(),
      });
      data.summary.rulesSedimented = data.rules.filter(r => (r as any).status !== 'pending').length;
      addEvent(data, 'rule_sedimented', { ruleId: localId, registryId: entry.id });
      addTimeline(data, 'rule', `${localId}: ${content.substring(0, 50)}`);
      save(path, data);
    
      // Rebuild markdown views so AI can read rules next session
      buildRuleViews(projectRoot);
    
      return { success: true, ruleId: entry.id, message: `规则已沉淀: ${entry.id} [${category}] ${content.substring(0, 60)}` };
    }
  • The `aida_log_rule` tool definition, including name, description, and input schema.
      name: 'aida_log_rule',
      description: '沉淀项目规则。当偏差的 rootCause 为 rule-missing 且修复方案属于项目级技术规范(非业务逻辑)时,询问用户同意后调用此工具沉淀规则。仅限:公共组件使用规范、API 调用规范、参数传递规范、代码风格/架构规范。禁止沉淀业务逻辑。',
      inputSchema: {
        type: 'object',
        properties: {
          content: { type: 'string', description: '规则内容,简洁描述项目规范' },
          category: { type: 'string', enum: [...RULE_CATEGORIES], description: '规则分类' },
          sourceDeviation: { type: 'string', description: '关联的偏差 ID,如 DEV-01' },
        },
        required: ['content', 'category'],
      },
    },
Behavior4/5

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

With no annotations provided, the description carries the full behavioral burden. It discloses the user-consent requirement and clearly defines scope boundaries (allowed categories vs prohibited business logic). It implies this is a persistent write operation but omits failure modes or idempotency details.

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

Conciseness4/5

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

Single complex sentence that efficiently packs purpose, condition, scope, and restrictions without redundancy. Information is front-loaded with the action (沉淀项目规则). Minor improvement possible by breaking into two sentences for readability.

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

Completeness4/5

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

Appropriate for a 3-parameter logging tool with no output schema. The description sufficiently covers domain-specific logic (technical vs business rules) and prerequisites (user consent). Could mention whether rule deposition is idempotent or what confirms success.

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

Parameters4/5

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

Schema coverage is 100% (baseline 3). The description adds semantic value by mapping the category enum values to concrete examples (公共组件使用规范→component, API调用规范→api, 代码风格/架构规范→style/architecture) and contextualizing sourceDeviation as linking to specific deviation IDs.

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

Purpose5/5

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

The description uses a specific verb (沉淀/deposit) with a specific resource (项目规则/project rules). It clearly distinguishes from sibling tools like aida_log_bug and aida_log_deviation by specifying this is specifically for rule-missing root causes and technical specifications.

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

Usage Guidelines5/5

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

Provides explicit triggering conditions (当偏差的 rootCause 为 rule-missing), scope restrictions (项目级技术规范 vs 业务逻辑), and clear prohibitions (禁止沉淀业务逻辑). It also notes the consent requirement (询问用户同意后), establishing a critical workflow constraint.

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/LWTlong/ai-dev-analytics'

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