Can the spell "Command" be used to cause unwitting damage?
RAW: Yes, you can, IF that damage is unbeknownst to the target (and in most cases the caster as well). You could not tell the target to walk off a cliff, jump into the spike pit, or smash its face into your Paladin's Warhammer. You could however tell the target to walk down a hallway you suspect but are not certain may contain traps. Why? Because it wouldn't be "directly harmful to it", it would be potentially indirectly harmful to it. What if it doesn't trigger any of the traps you aren't even sure are (and may not even be) down there? So no, it could not be used as a foolproof trap detector because unless the GM tells you and you (your character) becomes aware there are traps in said hallway, the spell would not fail. Let's say you poisoned one of their 5 rations and then told them to eat one? You can't be sure which one the target will eat, so it's still indirect.
As for the in-universe thought process? You are exactly correct. Self preservation would cause the magical command to fail, to cease functioning, to not take effect. If the target is unaware that it needs preserve its own life from something that might occur as a result of following the given command, then there would be no need for self preservation, and thus it would follow your command.
Proving a negative is impossible, of course, but I'm fairly confident that there are no general guidelines for creating magical items with triggers other than the main four from the question:
- Spell completion
- Spell trigger
- Command word
- Use activated
... plus continuous items.
However, the Contingency spell would probably be useful for the "when X happens, do Y" items.
For pricing such items, the only real rule is to find an existing item of similar power and price your item similarly. The Item Creation Rules have guidelines, and there's some evidence that an item that requires the "right" slot to duplicate a feat costs around 5k (eg., the Gloves of Arrow Snatching, which allow use of the Snatch Arrow feat twice per day), but the rule is to price it based on similarly-powerful items.
I would specifically recommend asking whether a generic character would buy the new item instead of a +X weapon, armor/shield, Stat item, or cloak of resistance: if a generic character is definitely going to buy the item instead of a +2 shield, the price should be higher than the 4k a +2 shield would cost; if it's a toss-up between the new item and a +1 weapon, a price of around 2k is probably about right. This is difficult, especially for new GMs or items that are highly situational (eg., the "self-destruct if a person is too far away from an item" item) or setting-dependent (eg., the auto-healer if divine magic is rare in "this" world).
In my experience, it's generally been best to err slightly on the side of making the item too expensive, then adding some extra treasure if need be.
Remember, too, that "Activating a magic item is a standard action unless the item description indicates otherwise." (Using Magic Items) The rules don't preclude magic items that can be activated as move/swift/free actions, they just don't provide much in the way of guidelines for making them.
That said, it's entirely possible to build most of the items in the question's list using just the Big 5 triggers:
- Self-destruct device if a person forgets some important item somewhere
- continuous item using Alarm and/or Scrying as a base requirement, plus a sufficiently powerful boom-ey spell
- Magical flashlight
- use activated or command word item based on several of the Evocation (light) spells, eg., light
- Booby-trapped bags of holding
- again, adding Alarm to the base requirements could serve to trigger the booby trap, as could simply calling it a variant Bag of Devouring
- Device that casts True Sight on owner when near evil-aligned characters, or perhaps Hide Alignment near good-aligned characters
- again, a continuous item with Alarm and the appropriate Detect spell (eg., Detect Evil)
- A crossbow that automatically fires a bolt when [given target] is in its cross hairs
- this is a reasonable interpretation for how True Strike works; an item that allows the wielder to use True Strike with a single attack from a weapon could be said to do this; similarly, Haste grants an extra attack in some situations...
- Necklace that casts a buff when its owner falls prone
- a constant item with Contingency as part of the creation process could probably do this
- Automatic potion-imbibing devices when its owner is low on HP.
- again, Contingency could probably be used in creating this
Best Answer
Seek refuge
That spell is likely the 7th-level cleric spell and 9th-level sorcerer/wizard spell refuge: "[Y]ou create powerful magic in a specially prepared object [that] contains the power to instantly transport its possessor across any distance within the same plane to your abode.… To make use of the item, the subject speaks the command word at the same time that it rends or breaks the item…."
It's an interesting spell, having a particularly dramatic effect on the plot when a refuge object is found secreted among a defeated foe's possessions.
Note: The spell refuge was called succor when it was published for Advanced Dungeon & Dragons in Unearthed Arcana (1985). It kept that name in Advanced Dungeon & Dragons, 2nd Edition where that edition's Player's Handbook made it a common spell. This reader fully supports the spell's 3e (and Pathfinder by extension) name change despite believing role-playing games a fantastic vocabulary-building tool.