Inflation is running amok in the U.S., and that's likely prompting a few fully justified questions about what to do with your portfolio. With so much uncertainty in the air, it's hard to feel confident about even basic things like whether to add to your positions or reduce them.

But you're not helpless in the face of inflation, and the answer regarding whether you should buy or sell stocks is also very much dependent on which stocks are under consideration. Let's take a look at a pair of arguments and a pair of stocks to weigh the possibilities.

Why it's tempting to sell

Between justified fears of inflation contributing to a prolonged bear market and the economic pressure that inflation inherently forces onto investors via rising prices, it's not shocking that people are thinking about selling stocks. Selling puts money into investors' accounts, and it also inoculates them against the anxiety caused by daily falling share prices. But, it's usually not a good idea as timing the market is a fool's errand that doesn't typically end well.

The reason why selling right now might not be a good decision is that there's a solid chance not much has changed over the last few months about a given company's ability to compete. Take CVS Health (CVS -0.65%), for example. The total return of its shares is down by about 11% so far this year, which isn't too bad compared to the market's decline of more than 20%.

But its competitive disposition hasn't changed. The products it sells, namely prescriptions and consumer health goods, aren't ones that people buy less of when prices are rising. That gives the company pricing power, which it can use to protect its margins even during inflation.

After all, you need to buy roughly the same amount of shampoo each month to stay clean, regardless of whether it's marginally more expensive than before. It would take a pretty fiendish rise in prices to change that, and such a change would probably only be temporary due to destruction of demand. Likewise, while its shares are down, it isn't as though any of CVS's competitors have made major inroads during this inflationary period.

Nor are fears of the Federal Reserve continuing to hike interest rates going to harm the company's ability to do business. With trailing 12-month revenue of nearly $299 billion, it isn't a growth-stage company -- and because it's profitable, it doesn't need to borrow to raise cash to open new retail locations or anything else. So rising borrowing costs aren't going to put a crimp in its ability to grow, and inflation isn't a major concern.

As for businesses in similar situations, where the ongoing economic phenomena aren't going to cause problems with growth or margin maintenance, it simply doesn't make sense to sell. 

Why it's probably better to buy

Warren Buffett's timeless advice to "be fearful when others are greedy and to be greedy only when others are fearful" is as relevant as ever. The level of fear about inflation in the market right now is driving stocks down, and in many cases -- as demonstrated by CVS -- the downward movements are not always prompted by genuine reductions in companies' abilities to grow or compete.

Therefore, generally speaking, if you have your eye on a stock and your investing thesis for it isn't negatively impacted by ongoing economic events, it's probably as good a time as ever to buy it. 

That's especially true for shares of under-the-weather evergreen stocks like Costco Wholesale (COST -0.12%). Much like CVS, its stock is down by more than 18% this year, but it's still profitable, and its discount warehouse business model is as in-demand as ever. Costco's huge range of products include many consumer staples like groceries and toilet paper, so its base of revenue, which totaled $195.9 billion in 2021, is relatively secure from inflation-linked headwinds. And people might even want to shop at its warehouses more if they think they'll get a better deal there amid rising prices. 

In a nutshell, you're leaving money on the table if you were thinking of buying Costco shares and inflation made you hesitate. It's true that it certainly feels safer to sit on the sidelines when things seem like they're going haywire, but the whole point of inflation is that it makes cash less valuable over time, which means the feeling of safety is an illusion.

People fled from their positions in the stock due to fear, and the lower share price caused by their fear just might be the starting point for your future gains once the market recovers, so buy away if you've found a stable, growing company like Costco that's just as healthy this year as the year before.