Welcome to TeX StackExchange.
You mentioned you wanted to write your own class with .sty extension, these kinds of files are called packages not classes. I assume you want to create a template to ease and standardize the process of creating documents for the future. If this is your goal, you should create a class, which has .cls extension.
Must-read before writing any kind of class or package is already installed on your system if LaTeX is properly installed. Just go to your terminal and type the following command
$ texdoc clsguide
or simply click here for the same content. I highly recommend getting familiar with texdoc command. Also, The LaTeX Companion and LaTeX: A Document Preparation System are two great resources.
After reading the clsguide, I you will grasp more about your problem and how things work for class and packages. If not, you will be able to express it more explicitly.
Have fun.
\RequirePackage{hyperref}does not make any harm if thehyperrefpackage is already loaded, therefore you can load it unconditionally. – Dec 30 '20 at 19:14\@ifpackageloaded{<name>}{<true>}{<false>}in the.styfile to test if a package has already been loaded. See also Test if a package (or package option) is loaded. But as @PM noted,\RequirePackageloads the package only if it hasn't been loaded yet, and otherwise does nothing. – gernot Dec 30 '20 at 20:13