Try the demo

rg: regex parse error: unclosed character class

You searched for code. ripgrep read it as a regular expression.

The error

> rg 'cfg[' src
rg: regex parse error:
    (?:cfg[)
          ^
error: unclosed character class

With a bracket of the other kind, it's error: unclosed group:

> rg 'log(' src
rg: regex parse error:
    (?:log()
    ^
error: unclosed group

Why it happens

rg treats every pattern as a regular expression. There, [ starts a set of characters and ( starts a group, and each must be closed. Code is full of both. The quieter case is worse: rg 'cfg["items"]' is a valid regex (cfg followed by one of the characters "items), so rg finds nothing and reports no error.

The fix

To search for text exactly as you typed it, add -F (fixed strings):

rg -F 'cfg[' src
rg -F 'log(' src

When you need a regex as well, escape the bracket instead: rg 'cfg\[' src.

In PowerShell, keep the pattern in single quotes so $ and backticks stay as they are. A double quote inside the pattern has its own catch, explained in The string is missing the terminator.

How DMN learned it

It came up, and was fixed, in 7 of our own sessions. DMN kept the fix as one line: In PowerShell, rg patterns containing \" or [[] fail to parse; pass each literal as a single-quoted -e 'pattern' with -F, or escape brackets as \[ instead.

DMN reads your agents' past sessions on your machine. When the same error is fixed the same way in two or more of them, it keeps the fix as a one-line lesson. When the error turns up again, Claude Code is told the fix straight away, and any agent can search what earlier sessions found. How DMN keeps what agents learn.

Stop fixing the same error twice