What cost basis is
Cost basis is what you are treated as having paid for a share, used to compute your gain: gain = sale price − cost basis. For a simple purchase it is the price you paid plus commissions. The lower your basis, the larger your taxable gain — which is why an incorrect, too-low basis costs you real money.
FIFO vs specific identification
When you own shares bought at different times and prices and sell only some, which lots you sell matters. The default is first-in, first-out (FIFO) — the oldest shares go first, which in a rising market means the lowest basis and the biggest gain. Specific identification lets you choose which lots to sell; picking high-basis lots shrinks the gain. To use it you must specify the lots at the time of sale and have your broker confirm them.
Basis for reinvested dividends
If you reinvest dividends (DRIP), each reinvestment buys new shares and adds to your basis. Forgetting this is a classic error: people are taxed on the dividend when it is paid, then taxed again on the full sale price because they did not add the reinvested amounts to basis. Keep the records, or you pay twice.
The equity-comp adjustment
Here is where most overpayment happens. For RSUs, basis is the vesting-date value. For NSOs, it is the fair market value at exercise. For ESPP, it is your purchase price plus the amount taxed as ordinary income. In every case the value already taxed as income is part of your basis — but brokers frequently report only what you paid out of pocket, or even $0.
The $0-basis trap
When a 1099-B shows a $0 or too-low basis on equity-comp shares, filing it unchanged taxes the compensation income a second time as a capital gain. The fix is to adjust the basis on Form 8949 (using adjustment codes) to the correct value. Your vesting statement, Form 3922 (ESPP) or Form 3921 (ISO), and exercise confirmations have the numbers. Checking this on every equity-comp sale is one of the highest-value few minutes in your whole return.
Keep the records
Basis problems are really record-keeping problems. Save vesting and exercise statements, ESPP Form 3922s, and DRIP confirmations. Brokers only track basis reliably for shares bought after basis-reporting rules took effect and rarely for compensation shares — so the responsibility to get it right is yours.