Yes, this is stimming, and not a healthy kind. If a stim hurts you, then it's not good for you, and it's best to reduce or replace it if you can. To start, only scratch areas of your skin that are covered by clothes, so that you're less likely to leave marks. Then, work on replacing with a safer stim , like brushing your skin with a brush, massaging yourself, or (safely) putting a cushion on yourself and stacking on heavy objects for deep pressure. Check out How to Stim for more ideas on safer ways to get similar sensory stimulation. Work on building healthy habits, and taking good care of your body, especially when you're stressed.