# How to find the undetected errors for general stabilizer codes in Stim?

In Stim, we use the detectors to track syndrome flips and infer the error pattern. However, the syndrome stays the same if the actual error pattern is a logical operator of the code by coincidence. It's easy to solve this problem on repetition codes since we can add detectors for each data qubit and compare them with the previous result. But for other codes, e.g., Steane code, the detectors can be triggered even if there is no error if we just measure all the data qubits because the codeword is a superposition of different binary strings. To properly detect all logical errors, do we need to implement the logical measurement circuit and append detectors after the logical measurement?

It sounds like you're confused about how error correcting codes work, but first I'll answer the title question.

How to find the undetected errors for general stabilizer codes in Stim?

There are three methods built into stim for doing this. In decreasing levels of generality:

the syndrome stays the same if the actual error pattern is a logical operator of the code by coincidence

This is true of all codes, including classical ones. The minimum number of errors that can do this is called the code distance of the code.

It's easy to solve this problem on repetition codes since we can add detectors for each data qubit and compare them with the previous result.

Do not do this! You have "solved" your problem by removing the ability of the code to store unmeasured information. The repetition code isn't punishing you for it, but a quantum code will. Using the repetition code in this way removes its ability to act as a simpler proxy for a quantum code.

To properly detect all logical errors, do we need to implement the logical measurement circuit and append detectors after the logical measurement?

It's impossible to detect all logical errors. There needs to be a way to edit the logical information intentionally, and there will always be some chance that the errors that occur exactly correspond to this set of operations. You can only make the probability of logical error exponentially small.