Your sentence is almost perfect! Here's the sentence: To escape, an octopus squirts a cloud of black ink and swims quickly away.
It is grammatically correct because:
- To escape is an infinitive phrase that shows the reason why the octopus squirts ink and swims away.
- An octopus squirts a cloud of black ink is a complete subject and verb phrase.
- And swims quickly away is another action happening right after squirting ink.
So, there is nothing wrong with the grammar in this sentence! It clearly tells us what the octopus does when it wants to escape.