Where are feat scripts stored and how to edit them?

I would like to look into few scripts and see how feats actually work. E.g. weapon proficiencies for adding completely new ones or at least adding new weapons for already existing ones.

Feats are defined in feat.2da.

If you want to see a specific example of new weapon feats, have a look at CEP 2. The container cep2_add_feats.hak has a version of feat.2da that enables feats for CEP 2’s unique weapons.

Many aspects of feats rely on hard-coding in the engine. However, more generally, you will notice that certain feats have associated spells, which (in spells.2da) identify scripts that run when the feat is activated.

I just checked spells.2da and unless I’m blind it seems that there aren’t any feats per se in this file only normal spells and spell-like feats (wildshape, assassin/blackguard spells or mount actions).
Also cep feats you refer to doesn’t really have any scripts reference in any of the 2da columns.

You’re making an invalid assumption. Feats are not primarily implemented as scripts. That’s why I said

You can learn more here, where you’ll find specific reference to weapon feats and their implementation, which further depends on baseitem.2da.

Feats are defined in feat.2da. If you look at the SPELL column in that file, you will see that a few feats have spells, for example, AnimalCompanion and WholenessofBody. These are references to spells.2da, where you will find the corresponding script. However, most feats don’t have spells.

For what concerns passive feats, In NWN1 there are at least two* ways to modify feats via scripts, the first one is to edit OnRest script, check if the target has the feat, and then apply a Permanent Supernatural Effect, the second one is via the OnEquip and OnUnequip script.
Three caveats before using this method:

  1. The first one, you must make sure to remove the spell effect before applying it, this is to avoid unproper stacking with itself, this may seem counterintuitive, but it’s necessary if you want to avoid "bugged scenarios where your characters gets buffed to infinite via certain stacking effects.
  2. The second one, is that not all modules have the same OnRest, OnEquip and OnUnequip module scripts attached, therefore modifying one of those scripts might work in a module, and do absolutely nothing in the other. The Original Campaign is particularly problematic in this sense as it uses unique scripts that you probably won’t find used anywhere else. NWN1 Enhanced Edition has a proper script command to change module scripts on the fly though, so it becomes easier to apply via Console code.
  3. These effects are removed on death, so they would have to be reapplied via rest or equip/unequip event.

however keep in mind that the hardcoded effects are untouchable, you can add additional effects, but you cannot remove or edit the hardcoded effect.
For example, you can modify the Blind Fight feat to make it grant Blindness Immunity if the character has 25 base CON or higher, but you cannot edit the reroll effects against targets with concealment.

I don’t remember if NWN1 has a “persistent” column in its feat.2da file, NWN has this method that properly hands passive feats through the spells.2da impact scripts, and in fact it would be the best method to implement them, but if absent, NWN1 has the 2 above mentioned workarounds available.

If you need to see examples, I might produce one later or in a few days.

I’d also like to add that, in addition to permanent supernatural effects, you can also use itemproperties on player skin, however that option is much more difficult to implement and requires very careful scripting, the risk of breaking a character is much higher.
On top of that it might interact badly with Polymorphed characters.