Brainfuck code optimization in Python
Some quick remarks:

You should be using the with..as construct when opening a file to ensure it is always closed, even if some intermediate code raises an exception:

with open(path) as f:
    text = f.read()
...
with open(path, 'w') as f:
    f.write(cmd)


I would save the comment commands in a set and outside of the loop. in is O(1) for sets and O(n) for tuples (even though n=4 here).

cmds = {'+-', '-+', '&lt;&gt;', '&gt;&lt;'}
found = True
while found:
    length = len(cmd)
    found = False
    for i in range(length-1):
        if cmd[i:i+2] in cmds:
            cmd = cmd[0:i] + cmd[i+2:length] # removing useless instruction pairs
            found = True


I would do the same with the longer command tuple before that:

comment_codes = {'+', '-', '&lt;', '&gt;', '.', ',', '[', ']'}
for c in text:
    if c in comment_codes:
        cmd += c


You could also use a generator comprehension and str.join here:

comment_codes = {'+', '-', '&lt;', '&gt;', '.', ',', '[', ']'}
cmd = "".join(c for c in text if c in comment_codes)


Your building of the output filename can be simplified using split and could use str.format:

name, ext = path.split('.')
path = '{}_opt.{}'.format(name, ext)