NASA astronauts once saved the International Space Station with an electric toothbrush. They were attempting to replace a power supply unit when they discovered the threads on a bolt were stuck. The tiny bristles on the toothbrush were just the thing to clean the edges, free the bolts, and assure mission success. Sometimes the best tool for the job isn't something you'll find in your tool kit.

The same lesson applies in retirement planning. If you're saving for retirement, take note: The health savings account is the best tool that's missing from your tool box.

HSA: The secret retirement weapon

Health savings accounts are designed to mitigate the costs incurred by people enrolled in high-deductible health insurance plans. The idea is straightforward: If your insurance policy has a high deductible, you'll likely be saddled with higher out-of-pocket costs for healthcare. So the government created the HSA, which allows accountholders to put their money in the account pre-tax, invest it, and let it grow. Then, when they need to pay a deductible, they can withdraw the funds tax-free, so long as they spend it on qualifying medical expenses. These include eyeglasses, diagnostic tests and services, prescriptions, dental treatments, and physical therapy. So there's no tax on the way in, and no tax on the way out. That's the magic of the HSA. However, it's important to remember that the money can only be used for medical expenses. Any non-medical withdraws before the retirement age of 65 are subject to income tax and a 20% penalty. After you reach 65, non-medical withdrawals are subject only to income tax.

Still don't see the retirement angle? Well, although the funds in an HSA are, in theory, supposed to cover qualifying healthcare expenses, there's no reason you have to use them anytime soon. Instead, you can simply let your contributions grow tax-free for decades. Here's how.

How to put an HSA to work

First, open an HSA and contribute as much as possible. The annual maximum as of 2017 is $3,400 if your health insurance only covers you, and it's $6,750 if the policy also covers family members. So if you max out your contribution, you can lower your taxable income by as much as $6,750, saving you money right off the bat. But wait, there's more.

Next, invest your HSA contribution in a well-diversified mutual fund with low costs (i.e., a low expense ratio). Then enroll in a high-deductible healthcare plan. Insurance policies with higher deductibles have lower monthly premiums, making them more affordable on a month-to-month basis. If you enroll in such a plan at a young age (the right time to start any retirement plan), you can reasonably expect fewer visits to the doctor and therefore fewer deductible payments. When you do face a deductible, try to pay it from your pocket and not from the HSA. Why? By leaving the money invested and untouched in the HSA, you're letting it experience the power of compound growth. Keep all your receipts and digital records of these out-of-pocket payments, as you'll need them for the last step.

Finally, when you're retired, you can withdraw the total of these receipts tax-free. You'll be supplementing your fixed income while still satisfying the rule that your withdrawals go toward qualifying medical expenses.

Some points of caution to consider

Like any retirement plan, this comes with a few risks. If you're fit as a fiddle throughout your adult life, you might not rack up enough healthcare payments to substantially grow the amount you can withdraw, which means you'll miss out on the full tax benefits. In such an event, you can still withdraw money from your HSA after the age of 65 without penalty. However, you'll face income tax on any distributions that are not for qualified medical expenses. This scenario is very similar to using a traditional IRA, which offers tax benefits on the way in but not on the way out.

Finally, to make this plan work, you'll need to have a personal budget that allows you to pay your deductibles out of pocket so that your HSA contributions can stay in the market and grow. This can be a challenge if you face an unexpected illness and you need to break the HSA bank to pay for it. However, even under this scenario, you're doing no worse than you would with a traditional IRA, so the HSA route is at least worth a shot. 

The Motley Fool has a disclosure policy.