Commander damage (formally called "combat damage" in the Commander rules) counts only combat damage dealt by a commander to a player. If a commander deals non-combat damage — through a spell, activated ability, triggered ability, or any other non-combat means — that damage does not count toward the 21-damage threshold.
This is defined in the official Commander format rules (rule 20 of the Commander Rules): a player who has been dealt 21 or more combat damage by a single commander over the course of the game loses the game. The key word is combat damage, which is damage dealt during the combat damage step (CR 510.2).
Non-combat damage a commander deals — such as its enters-the-battlefield ability, an activated ability that says "deals X damage," or a spell like Lightning Bolt it's animating — is never added to the commander damage tally, even though it still reduces the player's life total normally.
Concrete example: Your opponent controls Kaalia of the Vast (4/4 with flying). She attacks you and deals 4 combat damage — that's 4 commander damage. Later, a triggered ability she controls deals 3 damage to you. Those 3 points do NOT count as commander damage; only the 4 from combat does.
Relevant rules: CR 510.2 (combat damage step), CR 120.3 (sources of damage), and the Commander format rule specifying the 21 combat damage loss condition.
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.