How close to the magnetic poles will a compass be accurate?
Regions where the strength of the horizontal component (H) of the magnetic field is small (i.e. where the field is close to vertical near the magnetic poles) define where a compass won't work reliably.

For example where H drops below 5000nT is considered unreliable for values of magnetic declination as per the error calculations in the World Magnetic Model 2015 report. I've seen aviation charts (of which I can't find an example) where 6000nT (also based on the WMM as that's the industry standard there too) is used to define where another navigation aid should be take preference.

You can get an idea of the geographic distances involved from this map of the 2015 horizontal field intensity over the northern hemisphere. The distance of a given field strength value to the pole isn't a fixed value as the field isn't exactly a dipole, so the south pole map looks quite different, but you get a realistic idea at least. Something like within 2,500km in the North, and a few hundred km in the South.

As @Tactopoda pointed out, declination can be very large within thousands of km of a magnetic pole, and the annual rate of change of H is also much greater than elsewhere, hence why a compass isn't very reliable, even where it can give a consistent reading.