-cmd runs a dot-command before the query; combined, .mode csv and .headers on produce a CSV with a header row, ready for piping into other tools. Related: .import.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.