mastra-ai/mastra · error
Skipped: Scorer ${filename} already exists at ${scorersPath}
Error message
Skipped: Scorer ${filename} already exists at ${scorersPath} What it means
`writeScorer` refuses to overwrite an existing scorer file. Before writing, it checks fs.existsSync on the destination and throws this 'Skipped' error to protect the user's existing code from being clobbered by a generated scorer.
Source
Thrown at packages/cli/src/commands/scorers/file-utils.ts:25
export function writeScorer(filename: string, content: string, customPath?: string): { ok: true; message: string } {
const rootDir = process.cwd();
const scorersPath = customPath || DEFAULT_SCORERS_DIR;
const fullPath = path.join(rootDir, scorersPath);
if (!fs.existsSync(fullPath)) {
try {
fs.mkdirSync(fullPath, { recursive: true });
p.log.success(`Created scorers directory at ${scorersPath}`);
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to create directory: ${errorMessage}`);
}
}
const filePath = path.join(fullPath, filename);
if (fs.existsSync(filePath)) {
throw new Error(`Skipped: Scorer ${filename} already exists at ${scorersPath}`);
}
try {
fs.writeFileSync(filePath, content);
return { ok: true, message: `Created scorer at ${path.relative(rootDir, filePath)}` };
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to write scorer: ${errorMessage}`);
}
}
View on GitHub (pinned to 75dd419e61)
Solutions
- Delete or rename the existing scorer file, then rerun the command
- Choose a different scorer name in the command
- Merge the new scorer logic manually into the existing file
Example fix
// before scorers/my-scorer.ts already exists // after mv scorers/my-scorer.ts scorers/my-scorer.bak.ts # then rerun, or delete it if unwanted
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync, join } from 'node:fs'; // use path join
const target = join(scorersPath, filename);
if (existsSync(target)) {
console.log('Scorer already exists, skipping or renaming first.');
} Type guard
const isAvailable = (dir: string, name: string): boolean => !existsSync(join(dir, name));
Try / catch
try {
await writeScorer({ ... });
} catch (e) {
if ((e as Error).message.startsWith('Skipped: Scorer')) {
console.warn('Scorer file already exists — remove it or pick another name.');
} else throw e;
} Prevention
- Check for existing scorer files before generating
- Adopt a naming convention to avoid collisions
- Use unique scorer names per feature
- Clean generated scorers in CI before regeneration
When it happens
Trigger: Running a scorer add/generate command where <scorersPath>/<filename> already exists on disk.
Common situations: Re-running a scorer generation after an earlier successful run; generating a scorer with the same name in a different session; cloning a repo that already contains the scorer file.
Related errors
- Directory ${path.basename(targetPath)} already exists
- A file or directory named "${projectName}" already exists. P
- [FilesystemStorage] duplicate file path: ${file.path}
- Directory already exists and is not empty: ${targetDir}
- Project name must be 1-214 lowercase characters, start with
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/79dddf031b057f03.
Report an issue: GitHub.