davila7/claude-code-templates · warning

SEM_W001

SEM_W001

Error message

Suspicious instruction: Role pretending detected

What it means

SEM_W001 is a medium-severity warning matching /\bpretend\s+(you\s+are|to\s+be)\b/gi. Unlike the SEM_E* errors it belongs to SUSPICIOUS_PATTERNS and is surfaced as a warning, not a failure. It flags role-play framing ('pretend you are ...') because, while usually benign, it is the soft end of role-redefinition injection attacks.

Source

Thrown at cli-tool/src/validation/validators/SemanticValidator.js:87

      {
        pattern: /(forget|disregard|remove)\s+(everything|all\s+previous|prior\s+context)/gi,
        code: 'SEM_E009',
        message: 'Context manipulation attempt detected',
        severity: 'high'
      },
      {
        pattern: /modify\s+your\s+(own\s+)?(code|behavior|instructions?|rules?)/gi,
        code: 'SEM_E010',
        message: 'Self-modification request detected',
        severity: 'high'
      }
    ];

    // Suspicious patterns (warnings, not errors)
    this.SUSPICIOUS_PATTERNS = [
      {
        pattern: /\bpretend\s+(you\s+are|to\s+be)\b/gi,
        code: 'SEM_W001',
        message: 'Suspicious instruction: Role pretending detected',
        severity: 'medium'
      },
      {
        pattern: /\b(jailbreak|DAN|ChatGPT\s+Developer\s+Mode)\b/gi,
        code: 'SEM_W002',
        message: 'Known jailbreak terminology detected',
        severity: 'medium'
      },
      {
        pattern: /output\s+raw\s+(code|text|data)/gi,
        code: 'SEM_W003',
        message: 'Raw output request (potential data exfiltration)',
        severity: 'low'
      },
      {
        pattern: /(repeat|echo)\s+after\s+me/gi,
        code: 'SEM_W004',

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Usually no action needed — it's a warning; verify the roleplay is intentional and benign
  2. Rephrase to 'Act as ...' or 'Take the role of ...' to avoid the pattern entirely
  3. Keep the warning in the review report as an audit signal for human reviewers
  4. If warnings block your pipeline (strict mode), adjust the validation threshold or rephrase

Example fix

// before
Pretend you are a senior code reviewer giving feedback.

// after
Act as a senior code reviewer giving feedback.
Defensive patterns

Strategy: validation

Validate before calling

const PRETEND_RE = /\bpretend\s+(you\s+are|to\s+be)\b/i;
const warnings = (content.match(new RegExp(PRETEND_RE.source, 'gi')) || []).length;
if (warnings > 0) console.warn(`${warnings} roleplay warning(s); confirm they are intentional.`);

Type guard

function isSafeRoleplayText(text) { return !/\bpretend\s+(you\s+are|to\s+be)\b/i.test(text); }

Prevention

When it happens

Trigger: Component content containing 'pretend you are' or 'pretend to be' (case-insensitive, word-boundary anchored). Typical in persona, roleplay, simulation, and training-data generation components.

Common situations: Persona agents ('pretend you are a pirate debugger'); interview/simulation components; demo and educational prompt collections.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/9c1bca041f31e44f. Report an issue: GitHub.