@lousy-agents/lint

中文文档
5.22.24发布于 2026/11/02BSD-2-Clause-PatentTypeScriptES Module零依赖构建来源已验证

Programmatic lint API for validating AI coding assistant configurations — skills, agents, hooks, and instructions

原始使用文档
文档目录11 节
  1. Installation
  2. Quick Start
  3. API
  4. runLint(options): Promise<LintResult>
  5. createFormatter(format): LintFormatter
  6. DEFAULT_LINT_RULES
  7. LintValidationError
  8. Types
  9. Custom Logger
  10. CI Integration (rdjsonl)
  11. Related docs

@lousy-agents/lint

Programmatic lint API for AI agent skill, agent, hook, and instruction files. Use this package to integrate lousy-agents lint checks into your own tools, web apps, or CI pipelines without the CLI.

For CLI-based linting, see the lint command docs.

Installation

npm install @lousy-agents/lint

Quick Start

import { runLint } from '@lousy-agents/lint';

const result = await runLint({ directory: '/path/to/project' });

if (result.hasErrors) {
  console.error('Lint failed');
  for (const output of result.outputs) {
    for (const diagnostic of output.diagnostics) {
      console.error(`${diagnostic.filePath}:${diagnostic.line} [${diagnostic.severity}] ${diagnostic.message}`);
    }
  }
}

API

runLint(options): Promise<LintResult>

Runs all lint checks on a project directory and returns structured results.

import { runLint, LintValidationError } from '@lousy-agents/lint';

try {
  const result = await runLint({
    directory: '/path/to/project',
    targets: {
      skills: true,
      agents: true,
      hooks: false,       // skip hook linting
      instructions: false, // skip instruction linting
    },
  });

  console.log('Has errors:', result.hasErrors);
  console.log('Outputs:', result.outputs.length);
} catch (error) {
  if (error instanceof LintValidationError) {
    console.error('Invalid input:', error.message);
  } else {
    throw error;
  }
}

Options:

PropertyTypeRequiredDescription
directorystring✅Absolute or relative path to the project directory to lint
targets.skillsboolean—Lint skill frontmatter: .github/skills/*/SKILL.md, .claude/skills/*/SKILL.md, .agents/skills/*/SKILL.md, .pi/skills/*/SKILL.md, .pi/prompts/*/SKILL.md (skills listed in root skills-lock.json are omitted)
targets.agentsboolean—Lint agent frontmatter in .github/agents/**/*.md
targets.subagentsboolean—Flag-only (not GA) — lint Claude Code subagent frontmatter in .claude/agents/**/*.md. Never runs unless explicitly true, even when targets is entirely omitted
targets.hooksboolean—Lint hook configs: .github/hooks/agent-shell/hooks.json (Copilot), .claude/settings.json and .claude/settings.local.json (Claude); only when content has preToolUse / PreToolUse; symlinks skipped
targets.instructionsboolean—Lint instruction quality: .github/copilot-instructions.md, .github/instructions/*.md, .github/agents/*.md (dual-use with agents), root AGENTS.md, root CLAUDE.md
targets.mcpServersboolean—Flag-only (not GA) — validate MCP server config files: .mcp.json, .vscode/mcp.json. Never runs unless explicitly true, even when targets is entirely omitted
loggerLintLogger—Custom logger for gateway diagnostics (must have a .warn method); defaults to consola

When targets is omitted or all flags are false, the default-enabled targets run: skills, agents, hooks, instructions. subagents and mcpServers are flag-only — part of a phased rollout (see Construct coverage) — and only run when explicitly set to true, even if no other flags are set.

Discovery paths come from the canonical agentic location catalog in @lousy-agents/core, shared with doctor. Doctor may inventory additional constructs lint still does not validate (plugins, multi-harness instruction trees, etc.). Intentional differences: skills-lock.json filtering (lint only), hook PreToolUse / preToolUse content heuristic (lint only, applies only to the two .claude/settings*.json / .github/hooks/agent-shell/hooks.json exact paths — kept, not relaxed, for this rollout), and symlink policy (lint skips; doctor follows in-repo).

Throws LintValidationError when directory is empty, contains control characters, path traversal sequences, does not exist, or is not a directory.


createFormatter(format): LintFormatter

Creates an output formatter for rendering LintOutput[] to a string.

import { runLint, createFormatter } from '@lousy-agents/lint';

const result = await runLint({ directory: '/path/to/project' });
const formatter = createFormatter('human');
console.log(formatter.format(result.outputs));
FormatDescription
'human'Human-readable text, one diagnostic per line
'json'JSON array of all diagnostics
'rdjsonl'Reviewdog Diagnostic Format JSONL (one JSON object per line) — for CI integrations

DEFAULT_LINT_RULES

The default rule configuration used when no lousy-agents.config.ts is present. Use this to inspect or extend the default rule set.

import { DEFAULT_LINT_RULES } from '@lousy-agents/lint';

console.log(DEFAULT_LINT_RULES.skills);
// { 'skill/missing-name': 'error', 'skill/missing-description': 'error', ... }

LintValidationError

Thrown when user-supplied input fails validation. Catch this to distinguish user-input errors from system errors.

import { runLint, LintValidationError } from '@lousy-agents/lint';

try {
  await runLint({ directory: '' });
} catch (error) {
  if (error instanceof LintValidationError) {
    // directory was empty, missing, or not a directory
    console.error(error.message);
  }
}

Types

import type {
  LintResult,
  LintOutput,
  LintDiagnostic,
  LintSeverity,
  LintTarget,
  LintOptions,
  LintLogger,
  LintRulesConfig,
  LintFormatType,
  LintFormatter,
  InstructionQualityResult,
} from '@lousy-agents/lint';

Key types:

TypeDescription
LintResultTop-level result: outputs array + hasErrors boolean
LintOutputPer-target result: diagnostics, filesAnalyzed, summary, optional qualityResult
LintDiagnosticSingle diagnostic: filePath, line, severity, message, ruleId, target
LintSeverity"error" | "warning" | "info"
LintTarget"skill" | "agent" | "subagent" | "instruction" | "hook" | "mcp-server"
InstructionQualityResultInstruction quality scores and suggestions (populated when instructions target runs)

Custom Logger

Pass any object with a .warn method to suppress or redirect gateway diagnostics:

import { runLint } from '@lousy-agents/lint';
import { createLogger } from 'your-logger';

const logger = createLogger('lint');
await runLint({
  directory: '/path/to/project',
  logger: { warn: (msg, ...args) => logger.warn(msg, ...args) },
});

CI Integration (rdjsonl)

Output in Reviewdog Diagnostic Format for annotation-based CI feedback:

node -e "
const { runLint, createFormatter } = require('@lousy-agents/lint');
runLint({ directory: '.' }).then(r => {
  process.stdout.write(createFormatter('rdjsonl').format(r.outputs));
  process.exit(r.hasErrors ? 1 : 0);
});
"

  • lint CLI command — CLI-based linting with npx @lousy-agents/cli lint
  • GitHub Action — run linting in GitHub Actions without installing Node.js

版本与发布记录

@lousy-agents/lint 共发布 117 个版本,首次发布于 2026/04/15;过去 12 个月发布了 117 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.22.24latest2026/11/021 天前
5.22.232026/11/012 天前
5.22.222026/10/313 天前
5.22.212026/10/313 天前
5.22.202026/10/303 天前
5.22.192026/10/304 天前

关于 @lousy-agents/lint 的常见问题

@lousy-agents/lint 是什么?

用于验证AI编码助手配置的编程lint API -技能,代理,钩子和指令

如何安装 @lousy-agents/lint?

在项目目录运行 npm install @lousy-agents/lint,或使用 pnpm add / yarn add / bun add。

@lousy-agents/lint 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@lousy-agents/lint 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@lousy-agents/lint 可以商用吗?

@lousy-agents/lint 使用 BSD-2-Clause-Patent 许可。声明的许可为 BSD-2-Clause-Patent,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@lousy-agents/lint 还在维护吗?

最新版本 5.22.24 发布于 2026/11/02(1 天前);至今共发布 117 个版本,其中过去 12 个月发布了 117 个;首次发布于 2026/04/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。