Squirrels usually dig in planter boxes to bury or recover food, and loose, freshly turned soil is irresistible. The most reliable fix is to make the soil surface physically difficult to dig through. After planting, cover the exposed soil with a sheet of 1/2-inch hardware cloth or a sturdy garden net. Cut small slits for stems, then secure the edges to the inside of the box with zip ties, staples, or weighted battens. Leave no gaps; squirrels are persistent. For seedlings, use a wire cloche or a temporary cage until plants are established.
A heavy top dressing also helps. Use large pebbles, coarse bark, seashells, or decorative rocks rather than fine mulch. Press the soil down after watering and avoid leaving bare, fluffy soil around new plants. If you plant bulbs, put them in wire baskets or cover the area with hardware cloth.
Deterrents can supplement barriers: a capsaicin or garlic spray, commercial squirrel repellent, or motion-activated sprinkler may help, but reapply after rain and rotate tactics. Remove attractants such as spilled birdseed, pet food, compost scraps, and easy access to garbage. Reflective tape, wind chimes, or a water jet can startle squirrels, though they habituate quickly.
Avoid mothballs and other toxic products, especially in food-growing boxes. Combine a secure soil cover, heavy mulch, and a tidy food-free area; that is usually enough to stop squirrels from digging up your urban planter box.