Economists continue to signal that a recession might be on the way. We don't seem to be there yet, but high inflation and interest rates are slowing down the economy. Whether or not a technical recession happens, it's important to have a diversified portfolio with some recession-proof stocks so you're ready for any economic outcome.

If you're looking for some shares to beef up your holdings now -- ones that you can hold on to for long-term benefit -- consider buying Costco Wholesale (COST -1.78%) and TJX Companies (TJX -1.52%).

1. Costco: The cheapest prices around

When the economy is tight and shoppers are watching their wallets, Costco's prices become a shopping magnet. In any environment, Costco's model revolves around offering low prices, with just a slight markup to cover product costs and expenses, while taking in profits from membership fees.

This model generates even more traffic when families are feeling the effects of inflation. For example, Costco's sales still increased 6.5% over last year in the 2023 fiscal second quarter (ended Feb. 12). But that's a huge slowdown from double-digit growth it saw since the pandemic began.

People are starting to cut back, especially on expensive non-essentials. Average ticket (or purchase amount) remained about flat although it was up 1.9% in the U.S. However, traffic increased 5%. People might be buying fewer products or cheaper products overall, but they're doing more of their shopping at Costco. 

Costco's stock dropped after that report, which isn't surprising. It's partly because Costco's expensive stock can't support its high valuation if growth isn't so high, and partly because the market isn't always rational.

The hidden meaning of the report is that Costco is still a fantastic company with resilience in any market and tons of future opportunity. It's well run with lots of cash at its disposal. Renewal rates are at record highs of more than 90%, and millions of new members are joining to benefit from Costco's prices.

It's not just the business itself that's reliable when the economy is tight. Costco pays a dividend, and the income from dividend stocks is a very attractive feature under these circumstances. Costco's dividend yields a low rate at only 0.74%. But it has paid a fat special dividend of between $5 and $10 four times over the past 12 years, and judging by the average time between those payouts, it's due for another one any day.

Management has said it plans to pay more special dividends, but it has not yet specified when. Despite sales growth decelerating, profits are still growing. Costco is sitting on a nice pile of cash, so that payout could happen very soon.

2. TJX: A great hedge for challenging times

TJX CEO Ernie Herrman loves to stress that TJX posts some of its best performance when the economy is pressured. That's when customers who have less disposable income shift over to its off-price chain stores. These include TJ Maxx and Marshall's, or what it calls the Marmaxx division, its largest segment, in addition to Home Goods, and a few other brands and international stores.

Things look a little different this time around. The pandemic's effect on the company was unusual because it's the age of digital, and TJX doesn't have a large digital presence. It just doesn't work well with the stores' "treasure hunt" feel, one of its big draws for customers.

Merchandise changes quickly depending on what's available, and it's not an easy model to adapt online. Sales dropped at the beginning of the pandemic for several quarters when stores were closed, but they have completely recovered and are growing now.

Chart showing large drop in TJX's sales in 2020, followed by recovery.

TJX Revenue (Quarterly) data by YCharts

However, the Home Goods stores demonstrated high growth when they reopened to customer traffic and people were still looking for affordable home improvement solutions. They're having trouble topping that, and Home Goods' comparable sales fell 7% in the first quarter.

But the rest of the company made up for it, and overall TJX reported a 3% year-over-year sales increase in the fiscal 2024 first quarter (ended April 29). Management expects full-year comparable sales to increase 2% to 3%, and it raised earnings per share guidance to $3.49-$3.58, from $3.39-$3.51.

TJX's dividend yields 1.5%, which isn't the highest yield around. But it's a solid and reliable dividend, along with a stock that's likely to reward customers through challenging times and for many years.