I should have quoted more of the Ephesians reference, which gives a clearer picture of where good works fit into the picture:
"For by grace you have been saved through faith, and that not of yourselves; it is the gift of God, 9 not of works, lest anyone should boast. For we are His workmanship, created in Christ Jesus for good works, which God prepared beforehand that we should walk in them" (Ephesians 2:8-10).
So, the narrow gate is God's grace through faith and not of any works of righteousness that we can hold up to Him, because all our righteousness is as used sanitary pads to God (Isaiah 64:6). But once we have been through the narrow gate, then the good works we do that demonstrates our faith are those whom the Holy Spirit, who is God, leads us to walk in them. These are not the good works we do in the flesh, but those which the Holy Spirit inspires us to do, and so in being obedient to the prompting and leading of the Holy Spirit, we are being obedient to Jesus also, because both the Holy Spirit and Jesus are God.
Jesus carries His work of enlightening and teaching us the ways of God through the agency of the Holy Spirit. We see this extension through the teaching of Paul, Peter, John, and Jude. Their teaching is not inferior to the teaching that Jesus gave in His earthly ministry, because the inspiration of the Holy Spirit through the Apostles, is Jesus continuing to give His teaching to the church.
During the ministry of Jesus on earth, He gave His part 1 of His teaching to His disciples. When He was ascended, He sent the Holy Spirit to represent Him, and gave part 2 of His teaching through the Apostles. Part 2 gives the practical application of what He taught in part 1. Both part 1 and 2 are the teaching of Jesus to the church, because He and the Holy Spirit are God, so the teaching in both parts is from God, and originally comes from the Father, because Jesus said that He did only what the Father told him, and the Holy Spirit does only what Jesus tells Him to do. Therefore the teaching in the gospels and the Apostles come from the Father, Jesus, and the Holy Spirit.
So, when Jesus says that we are His friends if we do what He tells us, then the teaching of the Apostles is as much a part of that, and this is why we must study carefully what Paul, Peter, John, the Apostle to the Hebrews, and Jude teach, because they are the same words of Jesus, that He spoke in person to His disciples.