How create perfect mask using ID Pass ( "clown pass" in Photoshop)?
Workbench
It is not that easy :) and in some cases just impossible. If you want to just make parts darker or brighter, there is a change you just dont notice, but it would be there.
This &quot;imperfection&quot; comes from anti-aliased pixels generated on object edge to make them smooth. They consists partly from foreground color and partly from background color. So they are not purely defined only by single color.
To get a pixel perfect for selection you would have to render with Workbench &gt; Render Properties &gt; Sampling &gt; No-Anti-Aliasing, but this renderhas ugly pixelated edged. What people use to do is render double size of final render and downsize after compositing.

Cryptomatte
Feature designed to work with &quot;passes&quot;. Check some tutorials. Image saved as Open EXR Multilayer can store cryptomatte data and can be used also by other programs (like Fusion or Nuke). For work with Photoshop EXR – IO plugin should work for you (seems like only for Win).
Blender Manual – Cryptomatte
Cryptomatte tutorial example
Here I got a solution in Blender Compositor. Since this node tree based on InPaint node is technique before cryptomatte time it could work also on Workbench render too.
Result of default setup (issue on edge)

Result of edge refined by node group

Node Group

Detail default issue on edge vs refined edge. For the best result adjust ColorRamp nodes.