so far as i am aware, the most reliable way to take care of kobolds and such is to have a somewhat long hallway 3 squares wide leading into your fort, and a much shorter path with a locked door in it. sneaking enemies will go through the locked door, but your dwarfs won't be able to.
the next step is to pile a large number of unpleasant things (for example, magma) on top of the door, which should have an open space above it. think of it as being like the classic "bucket of water over the door" trap, except with mass quantities of burning hot magma or dozens of unused trap components and such. note that the door will not close until all the random stuff is no longer blocking it, by the way.... this makes hundreds of glass blades comical, but unfortunately will leave your door open (with no stuff falling from it when opened) and therefore somewhat unsafe... you may wish to chain multiple doors (and make sure you don't re-arm them until all door areas have been cleared) if you go the deadly object route.
so, the sneaking enemy takes the short route to your fortress, and makes the unfortunate choice of going through the door. it is also recommended that you install some form of drainage system in the area if you use magma... just make sure to leave enough room for the searing hot magma to do it's work before the magma all drains away
(hmmm... come to think of it, i bet you could make an inverted magma land mine that triggers when the door is opened too...)